Skip to content

armgit / nutch

Public Imported from GitHub
0

Apache Nutch is an extensible and scalable web crawler

NUTCH-1336 Optionally not index db_notmodified pages

Markus Jelsma5adf67b0ae6d
diff --git a/CHANGES.txt b/CHANGES.txt
index 739d07bcb..adbcc70e2 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -2,6 +2,8 @@ Nutch Change Log
(trunk) Current Development:
+* NUTCH-1336 Optionally not index db_notmodified pages (markus)
+
* NUTCH-1346 Follow outlinks to ignore external (markus)
* NUTCH-1320 IndexChecker and ParseChecker choke on IDN's (markus)
diff --git a/conf/nutch-default.xml b/conf/nutch-default.xml
index 1367fffcb..3ea154a58 100644
--- a/conf/nutch-default.xml
+++ b/conf/nutch-default.xml
@@ -875,6 +875,13 @@
</description>
</property>
+<property>
+ <name>indexer.skip.notmodified</name>
+ <value>false</value>
+ <description>Whether the indexer will skip records with a db_notmodified status.
+ </description>
+</property>
+
<!-- URL normalizer properties -->
<property>
diff --git a/src/java/org/apache/nutch/indexer/IndexerMapReduce.java b/src/java/org/apache/nutch/indexer/IndexerMapReduce.java
index 4a9102201..79e3dd658 100644
--- a/src/java/org/apache/nutch/indexer/IndexerMapReduce.java
+++ b/src/java/org/apache/nutch/indexer/IndexerMapReduce.java
@@ -55,7 +55,9 @@ implements Mapper<Text, Writable, Text, NutchWritable>,
public static final Logger LOG = LoggerFactory.getLogger(IndexerMapReduce.class);
public static final String INDEXER_DELETE = "indexer.delete";
+ public static final String INDEXER_SKIP_NOTMODIFIED = "indexer.skip.notmodified";
+ private boolean skip = false;
private boolean delete = false;
private IndexingFilters filters;
private ScoringFilters scfilters;
@@ -65,6 +67,7 @@ implements Mapper<Text, Writable, Text, NutchWritable>,
this.filters = new IndexingFilters(getConf());
this.scfilters = new ScoringFilters(getConf());
this.delete = job.getBoolean(INDEXER_DELETE, false);
+ this.skip = job.getBoolean(INDEXER_SKIP_NOTMODIFIED, false);
}
public void map(Text key, Writable value,
@@ -87,8 +90,15 @@ implements Mapper<Text, Writable, Text, NutchWritable>,
inlinks = (Inlinks)value;
} else if (value instanceof CrawlDatum) {
final CrawlDatum datum = (CrawlDatum)value;
- if (CrawlDatum.hasDbStatus(datum))
+ if (CrawlDatum.hasDbStatus(datum)) {
dbDatum = datum;
+
+ // Whether to skip DB_NOTMODIFIED pages
+ if (skip && dbDatum.getStatus() == CrawlDatum.STATUS_DB_NOTMODIFIED) {
+ reporter.incrCounter("IndexerStatus", "Skipped", 1);
+ return;
+ }
+ }
else if (CrawlDatum.hasFetchStatus(datum)) {
// don't index unmodified (empty) pages
@@ -104,14 +114,14 @@ implements Mapper<Text, Writable, Text, NutchWritable>,
NutchIndexAction action = new NutchIndexAction(null, NutchIndexAction.DELETE);
output.collect(key, action);
- continue;
+ return;
}
if (fetchDatum.getStatus() == CrawlDatum.STATUS_FETCH_REDIR_PERM) {
reporter.incrCounter("IndexerStatus", "Perm redirects deleted", 1);
NutchIndexAction action = new NutchIndexAction(null, NutchIndexAction.DELETE);
output.collect(key, action);
- continue;
+ return;
}
}
}