Skip to content

Apache Lucene open-source search software

licensing

Yonik Seeleyfb358696c629
diff --git a/src/apps/SolrTest/cachetest.txt b/src/apps/SolrTest/cachetest.txt
index 4e8f10fbe2c..cc3b5d631c2 100644
--- a/src/apps/SolrTest/cachetest.txt
+++ b/src/apps/SolrTest/cachetest.txt
@@ -1,4 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
#change the query cache size to 3 and the autowarm size to 2 for this test
<commit/>
val_s:A
diff --git a/src/apps/SolrTest/commit.bat b/src/apps/SolrTest/commit.bat
index 50715f6b348..79969af1b7d 100644
--- a/src/apps/SolrTest/commit.bat
+++ b/src/apps/SolrTest/commit.bat
@@ -1,3 +1,18 @@
+echo off
+rem Licensed to the Apache Software Foundation (ASF) under one or more
+rem contributor license agreements. See the NOTICE file distributed with
+rem this work for additional information regarding copyright ownership.
+rem The ASF licenses this file to You under the Apache License, Version 2.0
+rem (the "License"); you may not use this file except in compliance with
+rem the License. You may obtain a copy of the License at
+rem
+rem http://www.apache.org/licenses/LICENSE-2.0
+rem
+rem Unless required by applicable law or agreed to in writing, software
+rem distributed under the License is distributed on an "AS IS" BASIS,
+rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+rem See the License for the specific language governing permissions and
+rem limitations under the License.
PATH=c:/cygwin/bin
c:/cygwin/bin/bash.exe -c "echo handler called... cwd=`pwd` MYVAR=%MYVAR% > commit.outfile"
diff --git a/src/apps/SolrTest/newtest.txt b/src/apps/SolrTest/newtest.txt
index 6ce86e22713..1a9d2be9531 100644
--- a/src/apps/SolrTest/newtest.txt
+++ b/src/apps/SolrTest/newtest.txt
@@ -1,3 +1,18 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
#compact the index, keep things from getting out of hand
<optimize/>
diff --git a/src/apps/SolrTest/solr/conf/protwords.txt b/src/apps/SolrTest/solr/conf/protwords.txt
index f668c1c0e35..485aa74b60a 100644
--- a/src/apps/SolrTest/solr/conf/protwords.txt
+++ b/src/apps/SolrTest/solr/conf/protwords.txt
@@ -1,5 +1,2 @@
-#use a protected word file to avoid stemming two
-#unrelated words to the same base word.
-#to test, we will use words that would normally obviously be stemmed.
cats
ridding
\ No newline at end of file
diff --git a/src/apps/SolrTest/solr/conf/schema.xml b/src/apps/SolrTest/solr/conf/schema.xml
index 5df0f62ca76..c1b4dd2053b 100644
--- a/src/apps/SolrTest/solr/conf/schema.xml
+++ b/src/apps/SolrTest/solr/conf/schema.xml
@@ -1,4 +1,21 @@
<?xml version="1.0" ?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
<!-- The Solr schema file. This file should be named "schema.xml" and
should be located where the classloader for the Solr webapp can find it.
diff --git a/src/apps/SolrTest/test_func.txt b/src/apps/SolrTest/test_func.txt
index 156f7435559..744d2049ce9 100644
--- a/src/apps/SolrTest/test_func.txt
+++ b/src/apps/SolrTest/test_func.txt
@@ -1,3 +1,18 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
<delete><query>id:[* TO *]</query></delete>
<optimize/>
diff --git a/src/java/org/apache/solr/util/doc-files/min-should-match.html b/src/java/org/apache/solr/util/doc-files/min-should-match.html
index 99521214d5b..fde1f9b8a60 100644
--- a/src/java/org/apache/solr/util/doc-files/min-should-match.html
+++ b/src/java/org/apache/solr/util/doc-files/min-should-match.html
@@ -1,4 +1,20 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
<html>
<head>
<title>Min Number Should Match Specification Format</title>
diff --git a/src/test/org/apache/solr/update/TestCSVLoader.java b/src/test/org/apache/solr/update/TestCSVLoader.java
new file mode 100755
index 00000000000..4ee9658cdb2
--- /dev/null
+++ b/src/test/org/apache/solr/update/TestCSVLoader.java
@@ -0,0 +1,236 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.update;
+
+import org.apache.solr.util.AbstractSolrTestCase;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.core.SolrException;
+
+import java.io.*;
+
+public class TestCSVLoader extends AbstractSolrTestCase {
+
+ public String getSchemaFile() { return "schema.xml"; }
+ public String getSolrConfigFile() { return "solrconfig.xml"; }
+
+ String filename = "solr_tmp.csv";
+ String def_charset = "UTF-8";
+ File file = new File(filename);
+
+ public void setUp() throws Exception {
+ // if you override setUp or tearDown, you better call
+ // the super classes version
+ super.setUp();
+ }
+ public void tearDown() throws Exception {
+ // if you override setUp or tearDown, you better call
+ // the super classes version
+ super.tearDown();
+ deleteFile();
+ }
+
+ void makeFile(String contents) {
+ makeFile(contents,def_charset);
+ }
+
+ void makeFile(String contents, String charset) {
+ try {
+ Writer out = new OutputStreamWriter(new FileOutputStream(filename), charset);
+ out.write(contents);
+ out.close();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ void deleteFile() {
+ file.delete();
+ }
+
+ void cleanup() {
+ assertU(delQ("id:[100 TO 110]"));
+ assertU(commit());
+ }
+
+ public void testNoFile() throws Exception {
+ deleteFile();
+ SolrQueryRequest req = req("file",filename);
+ try {
+ CSVLoader.loadLocalFile(req);
+ } catch (SolrException e) {
+ assertEquals(400,e.code());
+ }
+ }
+
+ void loadLocal(String... args) {
+ SolrQueryRequest req = req(args);
+ CSVLoader.loadLocalFile(req);
+ }
+
+ public void testCSVLoad() throws Exception {
+ makeFile("id\n100\n101\n102");
+ loadLocal("file",filename);
+ // csv loader currently defaults to committing
+ // assertU(commit());
+ assertQ(req("id:[100 TO 110]"),"//*[@numFound='3']");
+ }
+
+ public void testCommitFalse() throws Exception {
+ makeFile("id\n100\n101\n102");
+ loadLocal("file",filename,"commit","false");
+ assertQ(req("id:[100 TO 110]"),"//*[@numFound='0']");
+ assertU(commit());
+ assertQ(req("id:[100 TO 110]"),"//*[@numFound='3']");
+ }
+
+ public void testCommitTrue() throws Exception {
+ makeFile("id\n100\n101\n102");
+ loadLocal("file",filename,"commit","true");
+ assertQ(req("id:[100 TO 110]"),"//*[@numFound='3']");
+ }
+
+ public void testCSV() throws Exception {
+ makeFile("id,str_s\n100,\"quoted\"\n101,\n102,\"\"\n103,");
+ loadLocal("file",filename,"commit","true");
+ assertQ(req("id:[100 TO 110]"),"//*[@numFound='4']");
+ assertQ(req("id:100"),"//str[@name='str_s'][.='quoted']");
+ assertQ(req("id:101"),"count(//str[@name='str_s'])=0");
+ // 102 is a quoted zero length field ,"", as opposed to ,,
+ // but we can't distinguish this case (and it's debateable
+ // if we should). Does CSV have a way to specify missing
+ // from zero-length?
+ assertQ(req("id:102"),"count(//str[@name='str_s'])=0");
+ assertQ(req("id:103"),"count(//str[@name='str_s'])=0");
+
+ // test overwrite by default
+ loadLocal("file",filename, "commit","true");
+ assertQ(req("id:[100 TO 110]"),"//*[@numFound='4']");
+
+ // test no overwrites
+ loadLocal("file",filename, "commit","true", "overwrite","false");
+ assertQ(req("id:[100 TO 110]"),"//*[@numFound='8']");
+
+ // test overwrite
+ loadLocal("file",filename, "commit","true");
+ assertQ(req("id:[100 TO 110]"),"//*[@numFound='4']");
+
+ // test global value mapping
+ loadLocal("file",filename, "commit","true", "map","quoted:QUOTED");
+ assertQ(req("id:[100 TO 110]"),"//*[@numFound='4']");
+ assertQ(req("id:100"),"//str[@name='str_s'][.='QUOTED']");
+ assertQ(req("id:101"),"count(//str[@name='str_s'])=0");
+ assertQ(req("id:102"),"count(//str[@name='str_s'])=0");
+ assertQ(req("id:103"),"count(//str[@name='str_s'])=0");
+
+ // test value mapping to empty (remove)
+ loadLocal("file",filename, "commit","true", "map","quoted:");
+ assertQ(req("id:[100 TO 110]"),"//*[@numFound='4']");
+ assertQ(req("id:100"),"count(//str[@name='str_s'])=0");
+
+ // test value mapping from empty
+ loadLocal("file",filename, "commit","true", "map",":EMPTY");
+ assertQ(req("id:[100 TO 110]"),"//*[@numFound='4']");
+ assertQ(req("id:100"),"//str[@name='str_s'][.='quoted']");
+ assertQ(req("id:101"),"//str[@name='str_s'][.='EMPTY']");
+ assertQ(req("id:102"),"//str[@name='str_s'][.='EMPTY']");
+ assertQ(req("id:103"),"//str[@name='str_s'][.='EMPTY']");
+
+ // test multiple map rules
+ loadLocal("file",filename, "commit","true", "map",":EMPTY", "map","quoted:QUOTED");
+ assertQ(req("id:[100 TO 110]"),"//*[@numFound='4']");
+ assertQ(req("id:100"),"//str[@name='str_s'][.='QUOTED']");
+ assertQ(req("id:101"),"//str[@name='str_s'][.='EMPTY']");
+ assertQ(req("id:102"),"//str[@name='str_s'][.='EMPTY']");
+ assertQ(req("id:103"),"//str[@name='str_s'][.='EMPTY']");
+
+ // test indexing empty fields
+ loadLocal("file",filename, "commit","true", "f.str_s.keepEmpty","true");
+ assertQ(req("id:[100 TO 110]"),"//*[@numFound='4']");
+ assertQ(req("id:100"),"//str[@name='str_s'][.='quoted']");
+ assertQ(req("id:101"),"//str[@name='str_s'][.='']");
+ assertQ(req("id:102"),"//str[@name='str_s'][.='']");
+ assertQ(req("id:103"),"//str[@name='str_s'][.='']");
+
+ // test overriding the name of fields
+ loadLocal("file",filename, "commit","true",
+ "fieldnames","id,my_s", "header","true",
+ "f.my_s.map",":EMPTY");
+ assertQ(req("id:[100 TO 110]"),"//*[@numFound='4']");
+ assertQ(req("id:100"),"//str[@name='my_s'][.='quoted']");
+ assertQ(req("id:101"),"count(//str[@name='str_s'])=0");
+ assertQ(req("id:102"),"count(//str[@name='str_s'])=0");
+ assertQ(req("id:103"),"count(//str[@name='str_s'])=0");
+ assertQ(req("id:101"),"//str[@name='my_s'][.='EMPTY']");
+ assertQ(req("id:102"),"//str[@name='my_s'][.='EMPTY']");
+ assertQ(req("id:103"),"//str[@name='my_s'][.='EMPTY']");
+
+ // test that header in file was skipped
+ assertQ(req("id:id"),"//*[@numFound='0']");
+
+ // test loading file as if it didn't have a header
+ loadLocal("file",filename, "commit","true",
+ "fieldnames","id,my_s", "header","false");
+ assertQ(req("id:id"),"//*[@numFound='1']");
+ assertQ(req("id:100"),"//str[@name='my_s'][.='quoted']");
+
+
+ // test multi-valued fields via field splitting w/ mapping of subvalues
+ makeFile("id,str_s\n"
+ +"100,\"quoted\"\n"
+ +"101,\"a,b,c\"\n"
+ +"102,\"a,,b\"\n"
+ +"103,\n");
+ loadLocal("file",filename, "commit","true",
+ "f.str_s.map",":EMPTY",
+ "f.str_s.split","true");
+ assertQ(req("id:[100 TO 110]"),"//*[@numFound='4']");
+ assertQ(req("id:100"),"//str[@name='str_s'][.='quoted']");
+ assertQ(req("id:101"),"//arr[@name='str_s']/str[1][.='a']");
+ assertQ(req("id:101"),"//arr[@name='str_s']/str[2][.='b']");
+ assertQ(req("id:101"),"//arr[@name='str_s']/str[3][.='c']");
+ assertQ(req("id:102"),"//arr[@name='str_s']/str[2][.='EMPTY']");
+ assertQ(req("id:103"),"//str[@name='str_s'][.='EMPTY']");
+
+
+ // test alternate values for delimiters
+ makeFile("id|str_s\n"
+ +"100|^quoted^\n"
+ +"101|a;'b';c\n"
+ +"102|a;;b\n"
+ +"103|\n");
+
+ loadLocal("file",filename, "commit","true",
+ "separator","|",
+ "encapsulator","^",
+ "f.str_s.map",":EMPTY",
+ "f.str_s.split","true",
+ "f.str_s.separator",";",
+ "f.str_s.encapsulator","'"
+ );
+ assertQ(req("id:[100 TO 110]"),"//*[@numFound='4']");
+ assertQ(req("id:100"),"//str[@name='str_s'][.='quoted']");
+ assertQ(req("id:101"),"//arr[@name='str_s']/str[1][.='a']");
+ assertQ(req("id:101"),"//arr[@name='str_s']/str[2][.='b']");
+ assertQ(req("id:101"),"//arr[@name='str_s']/str[3][.='c']");
+ assertQ(req("id:102"),"//arr[@name='str_s']/str[2][.='EMPTY']");
+ assertQ(req("id:103"),"//str[@name='str_s'][.='EMPTY']");
+ }
+
+
+
+}