Skip to content

armgit / nutch

Public Imported from GitHub
0

Apache Nutch is an extensible and scalable web crawler

NUTCH-1381 Allow to override default subcollection field name

Markus Jelsmaef3bdd044487
diff --git a/CHANGES.txt b/CHANGES.txt
index 08a2db52d..abef77c60 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -2,6 +2,8 @@ Nutch Change Log
(trunk) Current Development:
+* NUTCH-1381 Allow to override default subcollection field name (markus)
+
* NUTCH-XX Commit to add configuration for separation of ant distribution targets (lewismc + jnioche)
Release 1.5 - 04/15/2012
diff --git a/conf/nutch-default.xml b/conf/nutch-default.xml
index dd4f79942..01ebf60da 100644
--- a/conf/nutch-default.xml
+++ b/conf/nutch-default.xml
@@ -1349,4 +1349,15 @@
your credentials.
</description>
</property>
+
+<!-- subcollection properties -->
+
+<property>
+ <name>subcollection.default.field</name>
+ <value>subcollection</value>
+ <description>
+ The default field name for the subcollections.
+ </description>
+</property>
+
</configuration>
diff --git a/src/plugin/subcollection/src/java/org/apache/nutch/indexer/subcollection/SubcollectionIndexingFilter.java b/src/plugin/subcollection/src/java/org/apache/nutch/indexer/subcollection/SubcollectionIndexingFilter.java
index ed302e90a..be39a4a28 100644
--- a/src/plugin/subcollection/src/java/org/apache/nutch/indexer/subcollection/SubcollectionIndexingFilter.java
+++ b/src/plugin/subcollection/src/java/org/apache/nutch/indexer/subcollection/SubcollectionIndexingFilter.java
@@ -38,6 +38,8 @@ import org.apache.nutch.crawl.Inlinks;
public class SubcollectionIndexingFilter extends Configured implements IndexingFilter {
+ private Configuration conf;
+
public SubcollectionIndexingFilter(){
super(NutchConfiguration.create());
}
@@ -45,11 +47,27 @@ public class SubcollectionIndexingFilter extends Configured implements IndexingF
public SubcollectionIndexingFilter(Configuration conf) {
super(conf);
}
+
+ /**
+ * @param Configuration conf
+ */
+ public void setConf(Configuration conf) {
+ this.conf = conf;
+ fieldName = conf.get("subcollection.default.fieldname", "subcollection");
+ }
+ /**
+ * @return Configuration
+ */
+ public Configuration getConf() {
+ return this.conf;
+ }
+
+
/**
* Doc field name
*/
- public static final String FIELD_NAME = "subcollection";
+ public static String fieldName = "subcollection";
/**
* Logger
@@ -65,7 +83,7 @@ public class SubcollectionIndexingFilter extends Configured implements IndexingF
private void addSubCollectionField(NutchDocument doc, String url) {
for (Subcollection coll : CollectionManager.getCollectionManager(getConf()).getSubCollections(url)) {
if (coll.getKey() == null) {
- doc.add(FIELD_NAME, coll.getName());
+ doc.add(fieldName, coll.getName());
} else {
doc.add(coll.getKey(), coll.getName());
}