Author: snagel
Date: Thu Jun 27 20:16:22 2013
New Revision: 1497557

URL: http://svn.apache.org/r1497557
Log:
NUTCH-1580 index-static returns object instead of value for index.static

Modified:
    nutch/trunk/CHANGES.txt
    nutch/trunk/conf/nutch-default.xml
    
nutch/trunk/src/plugin/index-static/src/java/org/apache/nutch/indexer/staticfield/StaticFieldIndexer.java
    
nutch/trunk/src/plugin/index-static/src/test/org/apache/nutch/indexer/staticfield/TestStaticFieldIndexerTest.java

Modified: nutch/trunk/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/nutch/trunk/CHANGES.txt?rev=1497557&r1=1497556&r2=1497557&view=diff
==============================================================================
--- nutch/trunk/CHANGES.txt (original)
+++ nutch/trunk/CHANGES.txt Thu Jun 27 20:16:22 2013
@@ -2,6 +2,8 @@ Nutch Change Log
 
 Nutch Development Trunk
 
+* NUTCH-1580 index-static returns object instead of value for index.static 
(Antoinette, lewismc, snagel)
+
 * NUTCH-1126 JUnit test for urlfilter-prefix (Talat UYARER via markus)
 
 Apache Nutch 1.7 Release - 06/20/2013 (mm/dd/yyyy)

Modified: nutch/trunk/conf/nutch-default.xml
URL: 
http://svn.apache.org/viewvc/nutch/trunk/conf/nutch-default.xml?rev=1497557&r1=1497556&r2=1497557&view=diff
==============================================================================
--- nutch/trunk/conf/nutch-default.xml (original)
+++ nutch/trunk/conf/nutch-default.xml Thu Jun 27 20:16:22 2013
@@ -1241,9 +1241,11 @@
   <name>index.static</name>
   <value></value>
   <description>
-  A simple plugin called at indexing that adds fields with static data. 
-  You can specify a list of fieldname:fieldcontent per nutch job.
-  It can be useful when collections can't be created by urlpatterns, 
+  Used by plugin index-static to adds fields with static data at indexing 
time. 
+  You can specify a comma-separated list of fieldname:fieldcontent per Nutch 
job.
+  Each fieldcontent can have multiple values separated by space, e.g.,
+    field1:value1.1 value1.2 value1.3,field2:value2.1 value2.2 ...
+  It can be useful when collections can't be created by URL patterns, 
   like in subcollection, but on a job-basis.
   </description>
 </property>

Modified: 
nutch/trunk/src/plugin/index-static/src/java/org/apache/nutch/indexer/staticfield/StaticFieldIndexer.java
URL: 
http://svn.apache.org/viewvc/nutch/trunk/src/plugin/index-static/src/java/org/apache/nutch/indexer/staticfield/StaticFieldIndexer.java?rev=1497557&r1=1497556&r2=1497557&view=diff
==============================================================================
--- 
nutch/trunk/src/plugin/index-static/src/java/org/apache/nutch/indexer/staticfield/StaticFieldIndexer.java
 (original)
+++ 
nutch/trunk/src/plugin/index-static/src/java/org/apache/nutch/indexer/staticfield/StaticFieldIndexer.java
 Thu Jun 27 20:16:22 2013
@@ -57,7 +57,9 @@ public class StaticFieldIndexer implemen
 
     if (this.addStaticFields == true) {
       for (Entry<String, String[]> entry : this.fields.entrySet()) {
-        doc.add(entry.getKey(), entry.getValue());
+        for (String val : entry.getValue()) {
+          doc.add(entry.getKey(), val);
+        }
       }
     }
     return doc;

Modified: 
nutch/trunk/src/plugin/index-static/src/test/org/apache/nutch/indexer/staticfield/TestStaticFieldIndexerTest.java
URL: 
http://svn.apache.org/viewvc/nutch/trunk/src/plugin/index-static/src/test/org/apache/nutch/indexer/staticfield/TestStaticFieldIndexerTest.java?rev=1497557&r1=1497556&r2=1497557&view=diff
==============================================================================
--- 
nutch/trunk/src/plugin/index-static/src/test/org/apache/nutch/indexer/staticfield/TestStaticFieldIndexerTest.java
 (original)
+++ 
nutch/trunk/src/plugin/index-static/src/test/org/apache/nutch/indexer/staticfield/TestStaticFieldIndexerTest.java
 Thu Jun 27 20:16:22 2013
@@ -100,11 +100,11 @@ public class TestStaticFieldIndexerTest 
     assertNotNull(doc);
     assertFalse("test if doc is not empty", doc.getFieldNames().isEmpty());
     assertEquals("test if doc has 3 fields", 3, doc.getFieldNames().size());
-    assertEquals("test if doc has field1", "val1",
-        ((String[]) doc.getField("field1").getValues().get(0))[0]);
-    assertEquals("test if doc has field2", "val2",
-        ((String[]) doc.getField("field2").getValues().get(0))[0]);
-    assertEquals("test if doc has field4", "val4",
-        ((String[]) doc.getField("field4").getValues().get(0))[0]);
+    assertTrue("test if doc has field1", doc.getField("field1").getValues()
+        .contains("val1"));
+    assertTrue("test if doc has field2", doc.getField("field2").getValues()
+        .contains("val2"));
+    assertTrue("test if doc has field4", doc.getField("field4").getValues()
+        .contains("val4"));
   }
 }


Reply via email to