Crawl and Index….. Nutch / elasticSearch – Partners in the making


In the internet era, there is an old tech saying – “Content is King”  (inspired by old Jungle saying from Phantom.. 🙂 )

One of the common challenges in content management system is to extract the latest information.  In the WWW world, it is commonly known as crawling.  The king of the crawler world is Apache nutch.

elasticsearch (no more just the new kid in town) has already established itself as one of the top search platforms.  It is only natural that companies are looking at using the both platforms together to achieve a better content management system specifically acquire, analyze, publish, search  phase.

Here’s a quick and dirty guide to get them up and running quickly.

1. Download nutch
3. Clean build
ant clean
4. Verify new local deploy created under NUTCH_HOME/rutime
5. Under bin sudirectory of local, create a new directory called urls
6. In urls create a new file called nutch.txt. Edit the file to add URLs to crawl
7. Enable crawler in conf/nutch-site.xml by adding the below lines within configuration tags
<value>My Nutch Spider</value>
8. Note the value and enter the same in conf/nutch-default.xml as the
value for <name></name>
9. Test by running the below command in local/bin

nutch crawl urls -dir /tmp -depth 2
Integrate Nutch and ES
1. Activate elasticsearch indexer plugin
Edit conf/nutch-site.xml

<description>Regular expression naming plugin directory names to
include. Any plugin not matching this expression is excluded.
In any case you need at least include the nutch-extensionpoints plugin. By
default Nutch includes crawling just HTML and plain text via HTTP,
and basic indexing and search plugins. In order to use HTTPS please enable
protocol-httpclient, but be aware of possible intermittent problems with the
underlying commons-httpclient library.

2. Verify and add ES specific properties to nutch-site.xlm

<!– Elasticsearch properties –>

<description>The hostname to send documents to using TransportClient. Either host
and port must be defined or cluster.</description>


<description>The cluster name to discover. Either host and potr must be defined
or cluster.</description>

<description>Default index to send documents to.</description>

<description>Maximum size of the bulk in number of documents.</description>

<description>Maximum size of the bulk in bytes.</description>

3. Create a new index in ES if it is not there already

curl -XPUT ‘http://localhost:9200/nutch/&#8217;