Index: conf/nutch-default.xml
===================================================================
--- conf/nutch-default.xml (revision 1241053)
+++ conf/nutch-default.xml (working copy)
@@ -1179,6 +1179,35 @@
+
+
+
+ index.parse.md
+
+
+ Comma-separated list of keys to be taken from the parse metadata to generate fields.
+ Can be used e.g. for 'description' or 'keywords' provided that these values are generated
+ by a parser.
+
+
+
+
+ index.content.md
+
+
+ Comma-separated list of keys to be taken from the content metadata to generate fields.
+
+
+
+
+ index.db.md
+
+
+ Comma-separated list of keys to be taken from the crawldb metadata to generate fields.
+ Can be used to index values propagated from the seeds with the plugin urlmeta
+
+
+
Index: CHANGES.txt
===================================================================
--- CHANGES.txt (revision 1241053)
+++ CHANGES.txt (working copy)
@@ -1,5 +1,7 @@
Nutch Change Log
+* NUTCH-1264 Configurable indexing plugin index-extra (jnioche)
+
* NUTCH-1242 Allow disabling of URL Filters in ParseSegment (Edward Drapkin via markus)
* NUTCH-1256 WebGraph to dump host + score (markus)
Index: src/plugin/index-metadata/ivy.xml
===================================================================
--- src/plugin/index-metadata/ivy.xml (revision 0)
+++ src/plugin/index-metadata/ivy.xml (revision 0)
@@ -0,0 +1,41 @@
+
+
+
+
+
+
+
+
+
+ Apache Nutch
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: src/plugin/index-metadata/src/java/org/apache/nutch/indexer/metadata/MetadataIndexer.java
===================================================================
--- src/plugin/index-metadata/src/java/org/apache/nutch/indexer/metadata/MetadataIndexer.java (revision 0)
+++ src/plugin/index-metadata/src/java/org/apache/nutch/indexer/metadata/MetadataIndexer.java (revision 0)
@@ -0,0 +1,100 @@
+/**
+ * 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.nutch.indexer.metadata;
+
+import java.util.HashMap;
+import java.util.Map.Entry;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.io.Text;
+import org.apache.nutch.crawl.CrawlDatum;
+import org.apache.nutch.crawl.Inlinks;
+import org.apache.nutch.indexer.IndexingException;
+import org.apache.nutch.indexer.IndexingFilter;
+import org.apache.nutch.indexer.NutchDocument;
+import org.apache.nutch.parse.Parse;
+
+/**
+ * Indexer which can be configured to extract metadata from the crawldb, parse metadata or content metadata.
+ * You can specify the properties "index.db", "index.parse" or "index.content" who's values are
+ * comma-delimited key1, key2, key3.
+ */
+
+public class MetadataIndexer implements IndexingFilter {
+ private Configuration conf;
+ private HashMap staticfields;
+ private static String[] dbFieldnames;
+ private static String[] parseFieldnames;
+ private static String[] contentFieldnames;
+ private static final String db_CONF_PROPERTY = "index.db.md";
+ private static final String parse_CONF_PROPERTY = "index.parse.md";
+ private static final String content_CONF_PROPERTY = "index.content.md";
+
+ public NutchDocument filter(NutchDocument doc, Parse parse, Text url,
+ CrawlDatum datum, Inlinks inlinks) throws IndexingException {
+
+ // just in case
+ if (doc == null)
+ return doc;
+
+ // add the fields from crawldb
+ if (dbFieldnames != null) {
+ for (String metatag : dbFieldnames) {
+ Text metadata = (Text) datum.getMetaData().get(
+ new Text(metatag));
+ if (metadata != null)
+ doc.add(metatag, metadata.toString());
+ }
+ }
+
+ // add the fields from parsemd
+ if (parseFieldnames != null) {
+ for (String metatag : parseFieldnames) {
+ String value = parse.getData().getParseMeta().get(metatag);
+ if (value != null)
+ doc.add(metatag, value);
+ }
+ }
+
+ // add the fields from contentmd
+ if (contentFieldnames != null) {
+ for (String metatag : contentFieldnames) {
+ String value = parse.getData().getContentMeta().get(metatag);
+ if (value != null)
+ doc.add(metatag, value);
+ }
+ }
+
+ return doc;
+ }
+
+ public void setConf(Configuration conf) {
+ this.conf = conf;
+ dbFieldnames = conf.getStrings(db_CONF_PROPERTY);
+ parseFieldnames = conf.getStrings(parse_CONF_PROPERTY);
+ contentFieldnames = conf.getStrings(content_CONF_PROPERTY);
+
+ // TODO check conflict between field names e.g. could have same label
+ // from different sources
+
+ }
+
+ public Configuration getConf() {
+ return this.conf;
+ }
+}
Index: src/plugin/index-metadata/plugin.xml
===================================================================
--- src/plugin/index-metadata/plugin.xml (revision 0)
+++ src/plugin/index-metadata/plugin.xml (revision 0)
@@ -0,0 +1,42 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: src/plugin/index-metadata/build.xml
===================================================================
--- src/plugin/index-metadata/build.xml (revision 0)
+++ src/plugin/index-metadata/build.xml (revision 0)
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
Index: src/plugin/build.xml
===================================================================
--- src/plugin/build.xml (revision 1241053)
+++ src/plugin/build.xml (working copy)
@@ -32,6 +32,7 @@
+
@@ -103,6 +104,7 @@
+