You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nutch.apache.org by jn...@apache.org on 2012/02/06 17:53:31 UTC
svn commit: r1241074 - in /nutch/trunk: ./ conf/ src/plugin/
src/plugin/index-metadata/ src/plugin/index-metadata/src/
src/plugin/index-metadata/src/java/ src/plugin/index-metadata/src/java/org/
src/plugin/index-metadata/src/java/org/apache/ src/plugin...
Author: jnioche
Date: Mon Feb 6 16:53:30 2012
New Revision: 1241074
URL: http://svn.apache.org/viewvc?rev=1241074&view=rev
Log:
NUTCH-1264 Index-metadata
Added:
nutch/trunk/src/plugin/index-metadata/
nutch/trunk/src/plugin/index-metadata/build.xml
nutch/trunk/src/plugin/index-metadata/ivy.xml
nutch/trunk/src/plugin/index-metadata/plugin.xml
nutch/trunk/src/plugin/index-metadata/src/
nutch/trunk/src/plugin/index-metadata/src/java/
nutch/trunk/src/plugin/index-metadata/src/java/org/
nutch/trunk/src/plugin/index-metadata/src/java/org/apache/
nutch/trunk/src/plugin/index-metadata/src/java/org/apache/nutch/
nutch/trunk/src/plugin/index-metadata/src/java/org/apache/nutch/indexer/
nutch/trunk/src/plugin/index-metadata/src/java/org/apache/nutch/indexer/metadata/
nutch/trunk/src/plugin/index-metadata/src/java/org/apache/nutch/indexer/metadata/MetadataIndexer.java
Modified:
nutch/trunk/CHANGES.txt
nutch/trunk/conf/nutch-default.xml
nutch/trunk/src/plugin/build.xml
Modified: nutch/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/nutch/trunk/CHANGES.txt?rev=1241074&r1=1241073&r2=1241074&view=diff
==============================================================================
--- nutch/trunk/CHANGES.txt (original)
+++ nutch/trunk/CHANGES.txt Mon Feb 6 16:53:30 2012
@@ -1,5 +1,7 @@
Nutch Change Log
+* NUTCH-1264 Configurable indexing plugin index-metadata (jnioche)
+
* NUTCH-1242 Allow disabling of URL Filters in ParseSegment (Edward Drapkin via markus)
* NUTCH-1256 WebGraph to dump host + score (markus)
Modified: nutch/trunk/conf/nutch-default.xml
URL: http://svn.apache.org/viewvc/nutch/trunk/conf/nutch-default.xml?rev=1241074&r1=1241073&r2=1241074&view=diff
==============================================================================
--- nutch/trunk/conf/nutch-default.xml (original)
+++ nutch/trunk/conf/nutch-default.xml Mon Feb 6 16:53:30 2012
@@ -1179,6 +1179,35 @@
</description>
</property>
+<!-- index-metadata plugin properties -->
+
+<property>
+ <name>index.parse.md</name>
+ <value></value>
+ <description>
+ 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.
+ </description>
+</property>
+
+<property>
+ <name>index.content.md</name>
+ <value></value>
+ <description>
+ Comma-separated list of keys to be taken from the content metadata to generate fields.
+ </description>
+</property>
+
+<property>
+ <name>index.db.md</name>
+ <value></value>
+ <description>
+ 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
+ </description>
+</property>
+
<!-- Temporary Hadoop 0.17.x workaround. -->
<property>
Modified: nutch/trunk/src/plugin/build.xml
URL: http://svn.apache.org/viewvc/nutch/trunk/src/plugin/build.xml?rev=1241074&r1=1241073&r2=1241074&view=diff
==============================================================================
--- nutch/trunk/src/plugin/build.xml (original)
+++ nutch/trunk/src/plugin/build.xml Mon Feb 6 16:53:30 2012
@@ -32,6 +32,7 @@
<ant dir="index-anchor" target="deploy"/>
<ant dir="index-more" target="deploy"/>
<ant dir="index-static" target="deploy"/>
+ <ant dir="index-metadata" target="deploy"/>
<ant dir="language-identifier" target="deploy"/>
<ant dir="lib-http" target="deploy"/>
<ant dir="lib-nekohtml" target="deploy"/>
@@ -103,6 +104,7 @@
<ant dir="index-anchor" target="clean"/>
<ant dir="index-more" target="clean"/>
<ant dir="index-static" target="clean"/>
+ <ant dir="index-metadata" target="clean"/>
<ant dir="language-identifier" target="clean"/>
<ant dir="lib-commons-httpclient" target="clean"/>
<ant dir="lib-http" target="clean"/>
Added: nutch/trunk/src/plugin/index-metadata/build.xml
URL: http://svn.apache.org/viewvc/nutch/trunk/src/plugin/index-metadata/build.xml?rev=1241074&view=auto
==============================================================================
--- nutch/trunk/src/plugin/index-metadata/build.xml (added)
+++ nutch/trunk/src/plugin/index-metadata/build.xml Mon Feb 6 16:53:30 2012
@@ -0,0 +1,22 @@
+<?xml version="1.0"?>
+<!--
+ 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.
+-->
+<project name="index-metadata" default="jar-core">
+
+ <import file="../build-plugin.xml"/>
+
+</project>
Added: nutch/trunk/src/plugin/index-metadata/ivy.xml
URL: http://svn.apache.org/viewvc/nutch/trunk/src/plugin/index-metadata/ivy.xml?rev=1241074&view=auto
==============================================================================
--- nutch/trunk/src/plugin/index-metadata/ivy.xml (added)
+++ nutch/trunk/src/plugin/index-metadata/ivy.xml Mon Feb 6 16:53:30 2012
@@ -0,0 +1,41 @@
+<?xml version="1.0" ?>
+
+<!--
+ 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.
+-->
+
+<ivy-module version="1.0">
+ <info organisation="org.apache.nutch" module="${ant.project.name}">
+ <license name="Apache 2.0"/>
+ <ivyauthor name="Apache Nutch Team" url="http://nutch.apache.org"/>
+ <description>
+ Apache Nutch
+ </description>
+ </info>
+
+ <configurations>
+ <include file="../../../ivy/ivy-configurations.xml"/>
+ </configurations>
+
+ <publications>
+ <!--get the artifact from our module name-->
+ <artifact conf="master"/>
+ </publications>
+
+ <dependencies>
+ </dependencies>
+
+</ivy-module>
Added: nutch/trunk/src/plugin/index-metadata/plugin.xml
URL: http://svn.apache.org/viewvc/nutch/trunk/src/plugin/index-metadata/plugin.xml?rev=1241074&view=auto
==============================================================================
--- nutch/trunk/src/plugin/index-metadata/plugin.xml (added)
+++ nutch/trunk/src/plugin/index-metadata/plugin.xml Mon Feb 6 16:53:30 2012
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<plugin
+ id="index-metadata"
+ name="Index Metadata"
+ version="1.0.0"
+ provider-name="nutch.org">
+
+ <runtime>
+ <library name="index-metadata.jar">
+ <export name="*"/>
+ </library>
+ </runtime>
+
+ <requires>
+ <import plugin="nutch-extensionpoints"/>
+ </requires>
+
+
+ <extension id="org.apache.nutch.indexer.metadata"
+ name="Nutch metadata indexer"
+ point="org.apache.nutch.indexer.IndexingFilter">
+ <implementation id="MetadataIndexer"
+ class="org.apache.nutch.indexer.metadata.MetadataIndexer"/>
+ </extension>
+
+</plugin>
Added: nutch/trunk/src/plugin/index-metadata/src/java/org/apache/nutch/indexer/metadata/MetadataIndexer.java
URL: http://svn.apache.org/viewvc/nutch/trunk/src/plugin/index-metadata/src/java/org/apache/nutch/indexer/metadata/MetadataIndexer.java?rev=1241074&view=auto
==============================================================================
--- nutch/trunk/src/plugin/index-metadata/src/java/org/apache/nutch/indexer/metadata/MetadataIndexer.java (added)
+++ nutch/trunk/src/plugin/index-metadata/src/java/org/apache/nutch/indexer/metadata/MetadataIndexer.java Mon Feb 6 16:53:30 2012
@@ -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 <value>key1, key2, key3</value>.
+ */
+
+public class MetadataIndexer implements IndexingFilter {
+ private Configuration conf;
+ private HashMap<String, String[]> 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;
+ }
+}