SpinSpire logo

Integrating Apache Solr with Drupal Autocomplete

Although Drupal has a good built-in search functionality that coumes out of the box, sometimes a client wants something more advanced and feature rich that scales well for a quickly growing website.  This is where Apache Solr comes into play.  Apache Solr is an open source project that is used on many high traffic websites like Zappos.com and is well integrated into Drupal.  Solr can run as a standalone full-text search server on a separate server box to reduce server load on a server where MySQL and PHP are running. Solr is considered the "gorilla" of search by many and anyone who has used it can attest to that.

To begin using Apache Solr 3.6.2 in a Drupal website the following files and modules will be needed to get started:

1. Apache Solr Search Integration - Download and Enable

2. Apache Solr Autocomplete - Download and Enable

3. Apache Solr 3.6.2 - Download the .tgz to your server box. Make sure it is outside your drupal installation folder and is outside of your web root/folder.

Once the above three steps are done, extract the contents of Apache Solr 3.6.2 to a directory like: /home/Servers. The next step is to copy the configuration files (all files) inside

sites/all/modules/apachesolr/solr-conf/solr-3.x/   to   /home/Servers/apache-solr-.3.x/example/solr/conf

Any files that have the same name can be renamed to (eg. schema.xml.bak) before copying them or then can be overriden, either way will work properly.  The first option is the preferred method in case anything goes wrong and you want to keep the original configuration files.

At this time the Apache Solr server can be started by going to the directory where you extracted Solr files from the .tgz archive (in my case it is /home/Servers/Apache-Solr-3.6.2/example) and running this command:

java -jar start.jar 

Note: you need java installed on your server to run the above command.

If you don't have java installed, run the following command to get the latest default JDK packages from the repository:

sudo apt-get install default-jdk

The last step is to go to admin/settings/apachesolr from the drupal toolbar, click on 'Advanced Configuration' and make Apache Solr as the default search

To check if everything is running properly, got to the Apache Sorl admin interface by visiting: http//localhost:8983/solr/admin. If the admin interface is visible then everything is set.

Apache Solr is a very large and complex project that has a lot of configuration that can be changed to improve your search, so go explore it and have fun with it.

tags: Knowledge Base drupal apache solr search