Apache Solr Search Integration

Last modified: November 10, 2009 - 19:30

This documentation is for the Apache Solr Search Integration module that integrates Drupal with a Solr server for searching.

There is another Drupal module for interfacing with Solr but it is currently less developed.

You should also read the README.txt as it may be more up to date than this page.

Use Solr 1.4 (trunk)

The Drupal 5 ApacheSolr module and pre DRUPAL-6--1-BETA6 versions may currently be compatible with Solr 1.3, but the 6.x beta6 and any subsequent versions require Solr 1.4.

Installation

Prerequisites: Java 5 or higher. PHP 5.2 is recommended, but PHP 5.1.4 will work if you install the into PHP the PECL json extension or (for those who cannot install PHP extensions) if you install the Zend Framework JSON classes as described in the README.txt

Install the the Apache Solr Drupal module files as you would any Drupal module.

Get the PHP library from the external project. The project is found at: http://code.google.com/p/solr-php-client/
From the apachesolr module directory, run this command:


Note that revision 6 is the currently tested and suggested revision. Make sure that the final directory is named SolrPhpClient under the apachesolr module directory.

If you are maintaing your code base in subversion, you may choose instead to use svn export or svn externals. For an export (writing a copy to your local directory without .svn file to track changes) use:

Instead of checking out, externals can be used too. Externals can be seen as (remote) symlinks in svn.

This requires your own project in your own svn repository, of course.

In the apachesolr module directory, issue the command:

svn propedit svn:externals

Your editor will open. Add a line
SolrPhpClient -r6 http://solr-php-client.googlecode.com/svn/trunk/

On exports and checkouts, svn will grab the externals, but it will keep the references on the remote server.

Those without svn, etc may also choose to try the bundled Acquia Search download, which includes all these items which are not in Drupal.org CVS due to use CVS policy. See the download link here: http://acquia.com/documentation/acquia-search/activation

You should now be able to enable the Drupal module, but you may wish to wait until Solr is running (see below).

Download Solr 1.4 from a mirror site (until release this is a nightly build form trunk):
http://people.apache.org/builds/lucene/solr/nightly/
http://www.apache.org/dyn/closer.cgi/lucene/solr/

Unpack the tarball somewhere not visible to the web (not in your apache docroot and not inside of your drupal directory).

The Solr download comes with an example application that you can use for testing, development, and even for smaller production sites. This application is found at apache-solr-nightly/example.

Move apache-solr-nightly/example/solr/conf/schema.xml and and solrconfig.xml rename it something like *.bak. Then copy the schema.xml and solrconfig.xml that come with the Apache Solr Drupal module to take their place.

Now start the Solr application by opening a shell, changing directory to apache-solr-nightly/example, and executing the command java -jar start.jar

Test that your Solr server is now available by visiting http://localhost:8983/solr/admin/

Now run cron on your Drupal site until your content is indexed.

Return field list when using Jetty http://localhost:8983/solr/admin/luke?numTerms=0&wt=json

Enable blocks for facets at Administer > Site building > Blocks.

Problem with some builds

fossie - September 9, 2009 - 14:54

Hello,

I installed like described above, but due some issues on the Apache Solr project, it didn't work.

According to this thread: http://drupal.org/node/552776 taking the latest nightly build (solr-2009-09-09.tgz in this case), did solve the problem.

So if anybody was strugling with this, re-download the code.

HTH,
Fossie

Solr Nightly Build

sphopkins - October 16, 2009 - 15:01

Using the Oct 16th build, I notice that the /logs directory is not in the build and that generates an error. Adding the directory clears the problem.

 
 

Drupal is a registered trademark of Dries Buytaert.