Skip to content

armgit / nutch

Public Imported from GitHub
0

Apache Nutch is an extensible and scalable web crawler

NUTCH-1580 index-static returns object instead of value for index.static

Sebastian Nagel350088d308e5
diff --git a/CHANGES.txt b/CHANGES.txt
index 65d81ecfd..df082fa74 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -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)
diff --git a/conf/nutch-default.xml b/conf/nutch-default.xml
index 8713d73fd..b799d9273 100644
--- a/conf/nutch-default.xml
+++ b/conf/nutch-default.xml
@@ -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>
diff --git a/src/plugin/index-static/src/java/org/apache/nutch/indexer/staticfield/StaticFieldIndexer.java b/src/plugin/index-static/src/java/org/apache/nutch/indexer/staticfield/StaticFieldIndexer.java
index 84ece9bb7..6d106047d 100644
--- a/src/plugin/index-static/src/java/org/apache/nutch/indexer/staticfield/StaticFieldIndexer.java
+++ b/src/plugin/index-static/src/java/org/apache/nutch/indexer/staticfield/StaticFieldIndexer.java
@@ -57,7 +57,9 @@ public class StaticFieldIndexer implements IndexingFilter {
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;
diff --git a/src/plugin/index-static/src/test/org/apache/nutch/indexer/staticfield/TestStaticFieldIndexerTest.java b/src/plugin/index-static/src/test/org/apache/nutch/indexer/staticfield/TestStaticFieldIndexerTest.java
index 6f8e52b23..65c274949 100644
--- a/src/plugin/index-static/src/test/org/apache/nutch/indexer/staticfield/TestStaticFieldIndexerTest.java
+++ b/src/plugin/index-static/src/test/org/apache/nutch/indexer/staticfield/TestStaticFieldIndexerTest.java
@@ -100,11 +100,11 @@ public class TestStaticFieldIndexerTest extends TestCase {
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"));
}
}