Thursday, April 15, 2010

ApacheSolr and Drupal

I will be using Apachesolr as a search solution for one of the Drupal based websites. Sorl is setup as the enterprise search server at my current client.

Earlier, I have worked with Google Appliance as the search server.

As a security requirement, the infrastructure team does not want Drupal application to write the index to the Solr server. They want solr to write the index (in the form of xml) to be stored in a directory. There would then be a script that copies over the xml to the actual index.

This allows us to have read only access to the index.

Issue - apachesolr module with SolrphpClient posts its xml to the solr server. We want to intercept the process of posting and write the index to a file at a given location.

Utilities involved - apachesolr module, tomcat server, solr server, SolrPhpClient

Solution - We are building a apachesolrExtension module that when enabled allows you to write the xml to a directory.
  1. Created a class Drupal_APache_Solr_service_extn class that extends Drupal_Apache_Solr_Service.
  2. Override _sendrawPost() method to write the xml index to a file rather than posting it to the solr server.
  3. Used the 'apachesolr_service_class' variable to make apachesolr_get_solr() load our class.
Apachesolr is a great module that also allows writing object oriented code to Drupal. I will post the module here soon.

2 comments:

Brad said...

Thanks for sharing the article .Solr can indeed be quite efficient for the Drupal based websites.I'll be awaiting ur next post.Meanwhile I also came across an interesting article sharing info. about solr / Drupal integration at http://www.lucidimagination.com/blog/2009/02/19/drupalorg-fires-up-on-solr/

Manasi said...

Thanks for your interest Brad ! You can download the module from here:
http://manasi.drupalgardens.com/content/apachesolr-extension-module