Note: The information contained in this post may be outdated!
Nutch by default indexes the entire HTML document, this means that basically every single word of a page is taken to the index of it. When you have common boxes on your web site, e.g. a sidebar or a footer (applies to almost all web sites nowadays), nutch takes the terms of those common boxes into the index of all crawled pages.
Searching for a term contained in one of those common boxes leads to loads of results, since this term is associated with all pages nutch has crawled so far.
Now I thought an ideal solution would be telling nutch to ignore specific sections. A good and common practice doing this kind of stuff is creating HTML comment tags, let’s say <!–nutch_noindex–> … content not to be indexed … <!–/nutch_noindex–> – these comments could then be wrapped around our sidebar or footer, preventing our nutchie from indexing it.
If this is what you are looking for, read on.
First of all, you need the sources. Check out the latest Revision from the SVN (trunk), or download a previous package. I would recommend checking out the sources via SVN, because I provide a SVN patch. 😉
You should have been configuring and running nutch before – this is not an out-of-the box guidance for installing or running nutch, I just want to demonstrate how to apply this patch.
1. Go to your nutch home directory (in my case /home/nutch/)
2. Check out nutch
# svn co http://svn.apache.org/repos/asf/lucene/nutch/trunk/
3. Download the patch file: DOMContentUtils.java.patch
4. Copy it to ~/src/plugin/parse-html/src/java/org/apache/nutch/parse/html
5. cd to that directory
6. Apply it using
# patch DOMContentUtils.java DOMContentUtils.java.patch
Now that the patch is applied, we are ready to compile our sources.
1. cd to nutch home
2. Build it with ant (the war file is needed for web deployment)
# ant war
This was basically it – you can go ahead with crawling some pages now.
Please note that this was built and tested with nutch version 1.0-dev, there might be differences implementing it with other source versions.