lucene-solr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yo...@apache.org
Subject svn commit: r480367 - in /incubator/solr/trunk/src: apps/SolrTest/ apps/SolrTest/solr/conf/ java/org/apache/solr/util/doc-files/ test/org/apache/solr/update/
Date Wed, 29 Nov 2006 03:25:53 GMT
Author: yonik
Date: Tue Nov 28 19:25:52 2006
New Revision: 480367

URL: http://svn.apache.org/viewvc?view=rev&rev=480367
Log:
licensing

Added:
    incubator/solr/trunk/src/test/org/apache/solr/update/
    incubator/solr/trunk/src/test/org/apache/solr/update/TestCSVLoader.java   (with props)
Modified:
    incubator/solr/trunk/src/apps/SolrTest/cachetest.txt
    incubator/solr/trunk/src/apps/SolrTest/commit.bat
    incubator/solr/trunk/src/apps/SolrTest/newtest.txt
    incubator/solr/trunk/src/apps/SolrTest/solr/conf/protwords.txt
    incubator/solr/trunk/src/apps/SolrTest/solr/conf/schema.xml
    incubator/solr/trunk/src/apps/SolrTest/test_func.txt
    incubator/solr/trunk/src/java/org/apache/solr/util/doc-files/min-should-match.html

Modified: incubator/solr/trunk/src/apps/SolrTest/cachetest.txt
URL: http://svn.apache.org/viewvc/incubator/solr/trunk/src/apps/SolrTest/cachetest.txt?view=diff&rev=480367&r1=480366&r2=480367
==============================================================================
--- incubator/solr/trunk/src/apps/SolrTest/cachetest.txt (original)
+++ incubator/solr/trunk/src/apps/SolrTest/cachetest.txt Tue Nov 28 19:25:52 2006
@@ -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

Modified: incubator/solr/trunk/src/apps/SolrTest/commit.bat
URL: http://svn.apache.org/viewvc/incubator/solr/trunk/src/apps/SolrTest/commit.bat?view=diff&rev=480367&r1=480366&r2=480367
==============================================================================
--- incubator/solr/trunk/src/apps/SolrTest/commit.bat (original)
+++ incubator/solr/trunk/src/apps/SolrTest/commit.bat Tue Nov 28 19:25:52 2006
@@ -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"

Modified: incubator/solr/trunk/src/apps/SolrTest/newtest.txt
URL: http://svn.apache.org/viewvc/incubator/solr/trunk/src/apps/SolrTest/newtest.txt?view=diff&rev=480367&r1=480366&r2=480367
==============================================================================
--- incubator/solr/trunk/src/apps/SolrTest/newtest.txt (original)
+++ incubator/solr/trunk/src/apps/SolrTest/newtest.txt Tue Nov 28 19:25:52 2006
@@ -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/>
 

Modified: incubator/solr/trunk/src/apps/SolrTest/solr/conf/protwords.txt
URL: http://svn.apache.org/viewvc/incubator/solr/trunk/src/apps/SolrTest/solr/conf/protwords.txt?view=diff&rev=480367&r1=480366&r2=480367
==============================================================================
--- incubator/solr/trunk/src/apps/SolrTest/solr/conf/protwords.txt (original)
+++ incubator/solr/trunk/src/apps/SolrTest/solr/conf/protwords.txt Tue Nov 28 19:25:52 2006
@@ -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

Modified: incubator/solr/trunk/src/apps/SolrTest/solr/conf/schema.xml
URL: http://svn.apache.org/viewvc/incubator/solr/trunk/src/apps/SolrTest/solr/conf/schema.xml?view=diff&rev=480367&r1=480366&r2=480367
==============================================================================
--- incubator/solr/trunk/src/apps/SolrTest/solr/conf/schema.xml (original)
+++ incubator/solr/trunk/src/apps/SolrTest/solr/conf/schema.xml Tue Nov 28 19:25:52 2006
@@ -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.
 

Modified: incubator/solr/trunk/src/apps/SolrTest/test_func.txt
URL: http://svn.apache.org/viewvc/incubator/solr/trunk/src/apps/SolrTest/test_func.txt?view=diff&rev=480367&r1=480366&r2=480367
==============================================================================
--- incubator/solr/trunk/src/apps/SolrTest/test_func.txt (original)
+++ incubator/solr/trunk/src/apps/SolrTest/test_func.txt Tue Nov 28 19:25:52 2006
@@ -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/>
 

Modified: incubator/solr/trunk/src/java/org/apache/solr/util/doc-files/min-should-match.html
URL: http://svn.apache.org/viewvc/incubator/solr/trunk/src/java/org/apache/solr/util/doc-files/min-should-match.html?view=diff&rev=480367&r1=480366&r2=480367
==============================================================================
--- incubator/solr/trunk/src/java/org/apache/solr/util/doc-files/min-should-match.html (original)
+++ incubator/solr/trunk/src/java/org/apache/solr/util/doc-files/min-should-match.html Tue
Nov 28 19:25:52 2006
@@ -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>

Added: incubator/solr/trunk/src/test/org/apache/solr/update/TestCSVLoader.java
URL: http://svn.apache.org/viewvc/incubator/solr/trunk/src/test/org/apache/solr/update/TestCSVLoader.java?view=auto&rev=480367
==============================================================================
--- incubator/solr/trunk/src/test/org/apache/solr/update/TestCSVLoader.java (added)
+++ incubator/solr/trunk/src/test/org/apache/solr/update/TestCSVLoader.java Tue Nov 28 19:25:52
2006
@@ -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']");
+  }
+
+  
+
+}

Propchange: incubator/solr/trunk/src/test/org/apache/solr/update/TestCSVLoader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/solr/trunk/src/test/org/apache/solr/update/TestCSVLoader.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: incubator/solr/trunk/src/test/org/apache/solr/update/TestCSVLoader.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL



Mime
View raw message