Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Nutch Wiki" for change 
notification.

The following page has been changed by JakeVanderdray:
http://wiki.apache.org/nutch/WritingPlugins

------------------------------------------------------------------------------
  }
  }}}
  
+ == The Indexer Extension ==
+ 
+ {{{
+ package org.apache.nutch.parse.recommended;
+ 
+ // JDK import
+ import java.util.logging.Logger;
+ 
+ // Nutch imports
+ import org.apache.nutch.util.LogFormatter;
+ import org.apache.nutch.fetcher.FetcherOutput;
+ import org.apache.nutch.indexer.IndexingFilter;
+ import org.apache.nutch.indexer.IndexingException;
+ import org.apache.nutch.parse.Parse;
+ 
+ // Lucene imports
+ import org.apache.lucene.document.Field;
+ import org.apache.lucene.document.Document;
+ 
+ public class RecommendedIndexer implements IndexingFilter {
+   public static final Logger LOG
+     = LogFormatter.getLogger(RecommendedIndexer.class.getName());
+   
+   public RecommendedIndexer() {
+   }
+ 
+   public Document filter(Document doc, Parse parse, FetcherOutput fo)
+     throws IndexingException {
+ 
+     String recommendation = parse.getData().get("Recommended");
+ 
+       if (recommendation != null) {
+                       Field recommendedField = Field.Text("recommended", 
recommendation);
+                       recommendedField.setBoost(5.0f);
+               doc.add(recommendedField);
+                       LOG.info("Added " + recommendation + " to the 
recommended Field");
+       }
+ 
+     return doc;
+   }
+ }
+ }}}
+ 
  == Getting Nutch to Use Your Plugin ==
  
  In order to get Nutch to use your plugin, you need to edit your 
conf/nutch-site.xml file and add in a block like this:

Reply via email to