lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From k...@apache.org
Subject svn commit: r1032433 - in /lucene/dev/trunk/solr: ./ contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/ contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/
Date Mon, 08 Nov 2010 00:58:31 GMT
Author: koji
Date: Mon Nov  8 00:58:31 2010
New Revision: 1032433

URL: http://svn.apache.org/viewvc?rev=1032433&view=rev
Log:
SOLR-1973: Empty fields in update messages confuse DataImportHandler

Modified:
    lucene/dev/trunk/solr/CHANGES.txt
    lucene/dev/trunk/solr/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/XPathRecordReader.java
    lucene/dev/trunk/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestXPathRecordReader.java

Modified: lucene/dev/trunk/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/CHANGES.txt?rev=1032433&r1=1032432&r2=1032433&view=diff
==============================================================================
--- lucene/dev/trunk/solr/CHANGES.txt (original)
+++ lucene/dev/trunk/solr/CHANGES.txt Mon Nov  8 00:58:31 2010
@@ -543,6 +543,8 @@ Bug Fixes
 
 * SOLR-2057: DataImportHandler never calls UpdateRequestProcessor.finish()
   (Drew Farris via koji)
+
+* SOLR-1973: Empty fields in XML update messages confuse DataImportHandler. (koji)
   
 Other Changes
 ----------------------

Modified: lucene/dev/trunk/solr/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/XPathRecordReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/XPathRecordReader.java?rev=1032433&r1=1032432&r2=1032433&view=diff
==============================================================================
--- lucene/dev/trunk/solr/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/XPathRecordReader.java
(original)
+++ lucene/dev/trunk/solr/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/XPathRecordReader.java
Mon Nov  8 00:58:31 2010
@@ -277,7 +277,7 @@ public class XPathRecordReader {
           if (event == END_ELEMENT) {
             if (flattenedStarts > 0) flattenedStarts--;
             else {
-              if (text.length() > 0 && valuesAddedinThisFrame != null) {
+              if (hasText && valuesAddedinThisFrame != null) {
                 valuesAddedinThisFrame.add(fieldName);
                 putText(values, text.toString(), fieldName, multiValued);
               }

Modified: lucene/dev/trunk/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestXPathRecordReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestXPathRecordReader.java?rev=1032433&r1=1032432&r2=1032433&view=diff
==============================================================================
--- lucene/dev/trunk/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestXPathRecordReader.java
(original)
+++ lucene/dev/trunk/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestXPathRecordReader.java
Mon Nov  8 00:58:31 2010
@@ -195,6 +195,29 @@ public class TestXPathRecordReader exten
   }
 
   @Test
+  public void testElems2LevelEmpty() {
+    String xml="<root>\n"
+             + "\t<a>\n"
+             + "\t   <b>\n\t  <x>x0</x>\n"
+             + "\t            <y>y0</y>\n"
+             + "\t   </b>\n"
+             + "\t   <b>\n\t  <x></x>\n"    // empty
+             + "\t            <y>y1</y>\n"
+             + "\t   </b>\n"
+             + "\t</a>\n"
+             + "</root>";
+    XPathRecordReader rr = new XPathRecordReader("/root/a");
+    rr.addField("a", "/root/a/b/x", true);
+    rr.addField("b", "/root/a/b/y", true);
+    List<Map<String, Object>> l = rr.getAllRecords(new StringReader(xml));
+    assertEquals(1, l.size());
+    assertEquals("x0",((List) l.get(0).get("a")).get(0));
+    assertEquals("y0",((List) l.get(0).get("b")).get(0));
+    assertEquals("",((List) l.get(0).get("a")).get(1));
+    assertEquals("y1",((List) l.get(0).get("b")).get(1));
+  }
+
+  @Test
   public void testMixedContent() {
     String xml = "<xhtml:p xmlns:xhtml=\"http://xhtml.com/\" >This text is \n" +
             "  <xhtml:b>bold</xhtml:b> and this text is \n" +
@@ -236,12 +259,16 @@ public class TestXPathRecordReader exten
   public void testElems2LevelWithAttrib() {
     String xml = "<root>\n\t<a>\n\t   <b k=\"x\">\n"
             + "\t                        <x>x0</x>\n"
-            + "\t                        <y>y0</y>\n"
+            + "\t                        <y></y>\n"  // empty
             + "\t                        </b>\n"
             + "\t                     <b k=\"y\">\n"
-            + "\t                        <x>x1</x>\n"
+            + "\t                        <x></x>\n"  // empty
             + "\t                        <y>y1</y>\n"
             + "\t                        </b>\n"
+            + "\t                     <b k=\"z\">\n"
+            + "\t                        <x>x2</x>\n"
+            + "\t                        <y>y2</y>\n"
+            + "\t                        </b>\n"
             + "\t                </a>\n"
             + "\t           <a>\n\t   <b>\n"
             + "\t                        <x>x3</x>\n"
@@ -256,8 +283,14 @@ public class TestXPathRecordReader exten
     rr.addField("y", "/root/a/b[@k]/y", true);
     List<Map<String, Object>> l = rr.getAllRecords(new StringReader(xml));
     assertEquals(2, l.size());
-    assertEquals(2, ((List) l.get(0).get("x")).size());
-    assertEquals(2, ((List) l.get(0).get("y")).size());
+    assertEquals(3, ((List) l.get(0).get("x")).size());
+    assertEquals(3, ((List) l.get(0).get("y")).size());
+    assertEquals("x0", ((List) l.get(0).get("x")).get(0));
+    assertEquals("", ((List) l.get(0).get("y")).get(0));
+    assertEquals("", ((List) l.get(0).get("x")).get(1));
+    assertEquals("y1", ((List) l.get(0).get("y")).get(1));
+    assertEquals("x2", ((List) l.get(0).get("x")).get(2));
+    assertEquals("y2", ((List) l.get(0).get("y")).get(2));
     assertEquals(0, l.get(1).size());
   }
 



Mime
View raw message