Skip to content

armgit / nutch

Public Imported from GitHub
0

Apache Nutch is an extensible and scalable web crawler

NUTCH-2172 index-more: document format of contenttype-mapping.txt

Sebastian Nagelb5fa3a811457
diff --git a/CHANGES.txt b/CHANGES.txt
index fa135a4aa..a39019bd0 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,5 +1,7 @@
Nutch Change Log
-
+
+* NUTCH-2172 index-more: document format of contenttype-mapping.txt (Nicola Tonellotto, snagel)
+
Nutch 1.11 Release 03/12/2015 (dd/mm/yyyy)
Release Report: http://s.apache.org/nutch11
diff --git a/conf/contenttype-mapping.txt.template b/conf/contenttype-mapping.txt.template
new file mode 100644
index 000000000..5571e19c8
--- /dev/null
+++ b/conf/contenttype-mapping.txt.template
@@ -0,0 +1,22 @@
+#
+# Mapping of detected content types (MIME types) to custom types (target types)
+# used by the plugin index-more when filling the index field `type'.
+#
+# Note: The mappings defined in this file are only active if the property
+# `moreIndexingFilter.mapMimeTypes' is true.
+#
+# Format (tab-separated plain text, comment lines start with `#'):
+#
+# <target type> <TAB> <detected type1> [<TAB> <detected type2> ...]
+#
+# Examples (comment in to activate):
+#
+# map XHTML to HTML
+#text/html application/xhtml+xml
+#
+# Map XHTML and HTML to a custom type "web page"
+#web page text/html application/xhtml+xml
+#
+# map various office document formats to a custom type "office document"
+#office document application/vnd.oasis.opendocument.text application/x-tika-msoffice application/msword
+#
diff --git a/src/plugin/index-more/src/java/org/apache/nutch/indexer/more/MoreIndexingFilter.java b/src/plugin/index-more/src/java/org/apache/nutch/indexer/more/MoreIndexingFilter.java
index 773887d25..6e64ede70 100644
--- a/src/plugin/index-more/src/java/org/apache/nutch/indexer/more/MoreIndexingFilter.java
+++ b/src/plugin/index-more/src/java/org/apache/nutch/indexer/more/MoreIndexingFilter.java
@@ -312,10 +312,12 @@ public class MoreIndexingFilter implements IndexingFilter {
}
private void readConfiguration() throws IOException {
+ LOG.info("Reading content type mappings from file contenttype-mapping.txt");
BufferedReader reader = new BufferedReader(
conf.getConfResourceAsReader("contenttype-mapping.txt"));
String line;
String parts[];
+ boolean formatWarningShown = false;
mimeMap = new HashMap<String, String>();
@@ -329,6 +331,12 @@ public class MoreIndexingFilter implements IndexingFilter {
for (int i = 1; i < parts.length; i++) {
mimeMap.put(parts[i].trim(), parts[0].trim());
}
+ } else {
+ LOG.warn("Wrong format of line: {}", line);
+ if (!formatWarningShown) {
+ LOG.warn("Expected format: <target type> <tab> <type1> [<tab> <type2> ...]");
+ formatWarningShown = true;
+ }
}
}
}