Skip to content

armgit / nutch

Public Imported from GitHub
0

Apache Nutch is an extensible and scalable web crawler

NUTCH-1258 MoreIndexingFilter should be able to read Content-Type from both parse metadata and content metadata

Markus Jelsma04c67ab2669a
diff --git a/CHANGES.txt b/CHANGES.txt
index 6b44f7d8c..da4342cba 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,5 +1,7 @@
Nutch Change Log
+* NUTCH-1258 MoreIndexingFilter should be able to read Content-Type from both parse metadata and content metadata (jnioche, markus)
+
* NUTCH-1293 IndexingFiltersChecker to store detected content type in crawldatum metadata (markus)
* NUTCH-1291 Fetcher to stringify exception on // unexpected exception (markus)
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 37c566fc6..677f25d2a 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
@@ -39,6 +39,7 @@ import org.apache.nutch.util.MimeUtil;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.io.Text;
+import org.apache.hadoop.io.Writable;
import java.text.ParseException;
import java.text.SimpleDateFormat;
@@ -71,14 +72,14 @@ public class MoreIndexingFilter implements IndexingFilter {
/** Get the MimeTypes resolver instance. */
private MimeUtil MIME;
- public NutchDocument filter(NutchDocument doc, Parse parse, Text url, CrawlDatum datum, Inlinks inlinks)
- throws IndexingException {
+ public NutchDocument filter(NutchDocument doc, Parse parse, Text url,
+ CrawlDatum datum, Inlinks inlinks) throws IndexingException {
String url_s = url.toString();
addTime(doc, parse.getData(), url_s, datum);
addLength(doc, parse.getData(), url_s);
- addType(doc, parse.getData(), url_s);
+ addType(doc, parse.getData(), url_s, datum);
resetTitle(doc, parse.getData(), url_s);
return doc;
@@ -184,9 +185,17 @@ public class MoreIndexingFilter implements IndexingFilter {
* @param url
* @return
*/
- private NutchDocument addType(NutchDocument doc, ParseData data, String url) {
+ private NutchDocument addType(NutchDocument doc, ParseData data, String url,
+ CrawlDatum datum) {
String mimeType = null;
- String contentType = data.getMeta(Response.CONTENT_TYPE);
+ String contentType = null;
+
+ Writable tcontentType = datum.getMetaData().get(
+ new Text(Response.CONTENT_TYPE));
+ if (tcontentType != null) {
+ contentType = tcontentType.toString();
+ } else
+ contentType = data.getMeta(Response.CONTENT_TYPE);
if (contentType == null) {
// Note by Jerome Charron on 20050415:
// Content Type not solved by a previous plugin