Skip to main content

Apache Nutch-Solr Integration

Apache Nutch-Solr Integration 

As of this writing, I am using Solr 4.8.0 and Nutch 1.8.0 binaries for the integration. Will catch up to later versions as and when my project requires.

We can cover installation and operation of Solr and Nutch separately and then talk about the integration. the version of Nutch that I am using is very closely built with Solr and the integration is very simple.

For simplicity sake, Ill stick to Linux environment for both as Nutch does not operate in windows natively.

Getting Solr to work


1. All you need to for Solr to work are the binaries. you can get them from their official page (version 4.8.0)

2. Extract the solr-4.8.0.zip in some location. for this tutorial, lets assume that its in /home/test/Research/solr 4.8.0/

3. Open terminal, navigate to /home/test/Research/solr-4.8.0/example/ and execute the following command to start solr server

java -jar start.jar 

4.  This command will successfully start up your solr, you can check the status by launching the following URL.

http://localhost:8983/solr 

5.  You can add stuff to the index and test the search functionality, using the examples provided. execute the following command to add an XML file to the index. 

Navigate to /home/test/Research/solr-4.8.0/example/exampledocs/ and execute:

java -jar post.jar solr.XML 


6. The above would've added the XML into the solr's index and you can query the content from it. Search for "solr" from the Query tab of Solr Admin web client, you can get it after choosing the default "collection1" core.


Configuring Nutch for Solr


Nutch 1.8 is directly compatible with Solr without any code modifications.

1. Get the latest Nutch distribution binaries from their download page

2. Extract he downloaded apache-nutch-1.8.zip file in some folder. Lets assume it is in /home/test/Research/apache-nutch-1.8

3. Put necessary configuration to connect to the proxy server, agent name and included plugins if there are any changes from the default.

the complete nutch-site.xml should look something like this:


<configuration>

<property>
 <name>http.agent.name</name>
 <value>Nutch Crawler</value>
</property>

<property>
  <name>plugin.includes</name>
  <value>protocol-httpclient||urlfilter-regex|parse-(html|tika)|index-(basic|anchor)|indexer-solr|scoring-opic</value>
</property>

<property>
  <name>urlfilter.regex.file</name>
  <value>regex-urlfilter.txt</value>
</property>


<property>
  <name>http.proxy.host</name>
  <value>proxy-server</value>
</property>

<property>
  <name>http.proxy.port</name>
  <value>1234</value>
</property>

<property>
  <name>http.proxy.username</name>
  <value>username</value>
</property>

<property>
  <name>http.proxy.password</name>
  <value>password</value>
</property>

</configuration> 


The property highlighted in Blue is necessary for telling Nutch that the indexing is delegated to Solr and is available by default in nutch-default.xml

nutch-default.XML contains all the default configurations that are required for Nutch to run, If we want to over-ride any of the parameters, then we can specify the same in nutch-site.XML.

For example, the property "plugin.includes" specified above is not different from the one given in nutch-default.xml and hence can be removed from the nutch-site.XML without any effects to the current setup. It will still work the same way.


4. Put necessary field and fieldtype configuration from the schema.XML in Nutch to the solr's schema.XML. This change requires a restart of Solr server.


5. Create a folder "urls" under /home/test/Research/apache-nutch-1.8/ and put seed.txt file in it with the list of seed URLs that we want crawled.


6. Now that we have all the configurations out of the way, lets execute the following command to start crawling/indexing.

Navigate to /home/test/Research/apache-nutch-1.8/ folder in the terminal and execute


./bin/crawl urls crawl http://localhost:8983/solr 2 

format for using the crawl command is:

crawl <seed.txt folder> <crawl folder> <solr url> <rounds of iteration>

->urls folder created in step 5, contains the seed.txt which has the list of seed urls to crawl
->crawl folder contains the crawled objects which are to be indexed, these files are sent to Solr for indexing.
->Solr url for connecting and sending the data for indexing
->no clear documentation on this. However from the source, we can see that it iterates the crawling process given number of times as a fail safe when certain pages don't respond the first time. (correct me if I'm wrong) 


Once the crawl process completes, the data would have synced up to the Solr server, connect to the Solr admin console using the webclient and check if the documents have populated.


Do a initial search query, by choosing the default collection1 core and searching for a something from one of the pages in the website that you crawled.


More info & references:

Solr Tutorial - 4.8.0

Comments

  1. hi,

    Thanks for the helpful information.
    Im having problem with "java -jar post.jar solr.xml" command..

    $ java -jar post.jar solr.xml
    SimplePostTool version 5.0.0
    SimplePostTool: FATAL: Specifying either url or core/collection is mandatory.
    Usage: java [SystemProperties] -jar post.jar [-h|-] [ [...]]
    $

    Can you please help me with.

    Thanks.

    ReplyDelete

Post a Comment

Popular posts from this blog

Working!! is fun and satisfying

Working!! is an anime about the interesting things that happen in a family restaurant called Wagnaria, primarily about the staff that work there. Every character is quirky in someway or the other and it makes for some good comedy and drama. I’d like to go over the characters in the series in the order of their importance and talk about how I feel about them. Taneshima Popura: Taneshima is a high school senior who is very short, she is confused for an elementary student most of the time.  She is very upbeat and works hard, but has a huge complex about her height and is sometimes pranked upon by fellow workers in Wagnaria. Takanashi Souta: Takanashi is a junior to Taneshima and is recruited by her to work in Wagnaria at the start of the series. He likes all things tiny and deeply adores Taneshima.  He is level headed most of the time and works hard. He has three elder sisters and one younger sister whom he has to ...

Tobi is not Madara Uchiha and that is my verdict.

1. Zetsu’s Approach Zetsu keeps the name Tobi and he is the only person who is very close to Tobi, since he is a spy and has the most information in the entire Naruto universe, he exists everywhere planted beforehand blended with the environment. Zetsu also wonders how much Kabuto knows about them, in vary tone. They’ve got something to hide other than their fighting powers. Kabuto already knows most of their secrets which they’ve got hidden even from Akatsuki members to avoid an internal clash for power. 2. Tobi’s awe of Kabuto’s Re-animation. Okay, this is very very intriguing. Madara Uchiha is afraid of something; it’s also a very best kept secret. since Kabuto promises that he hasn't told a soul. Madara who can analyze and formulate any jutsu asks “how did you do this?” Who is he afraid of, let us think back, He is not afraid of anyone. He has had only reverence for Hashirama, even then it cannot be first or the second Hokages since they were sealed by the third H...

Don't go near cell phone towers...

AMCS/AT – Artificial Mind Control System / Artificial Telepathy Telepathy: Legilimency, Artificial Intelligence The March 23, 1991 ITV news brief "High-Tech Psychological Warfare Arrives in the Middle East" describes a US Psychological Operations (PsyOps) tactic directed against Iraqi troops in Kuwait during Operation Desert Storm. The maneuver consisted of a system in which subliminal mind-altering technology was carried on standard radio frequency broadcasts. The March 26, 1991 news brief states that among the standard military planning groups in the centre of US war planning operations at Riyadh was "an unbelievable and highly classified PsyOps program utilizing 'silent sound' techniques." The opportunity to use this method occurred when Saddam Hussein's military command-and-control system was destroyed. The Iraqi troops were then forced to use commercial FM radio stations to carry encoded commands, which were broadcast on the 100 MHz freque...