Version 2 (modified by 12 years ago) (diff) | ,
---|
Integrating Apache Solr Search
Solr is a standalone, full text search server that is considerably more powerful than the core search module provided by Drupal. Integrating an existing Solr server is accomplished by installing the Apache Solr Search Integration module. Download the 6.x-3.x version from http://drupal.org/project/apachesolr
Setting Up a Solr Server
(If a Solr server is already running, skip ahead to Configure Solr Integration.)
Download the latest 3.x version tarball of Apache Solr and extract it to /opt (or another appropriate location on the filesystem). Copy three configuration files from the solr-conf directory of the apachesolr Drupal module to the example/solr/conf of the Solr installation: schema.xml, solrconfig.xml, and protwords.text. Then, create a directory at example/solr/data and give the apache user (www-data, apache2, etc.) write access to the directory.
Solr can be started as a test by changing to the example directory of the Solr installation and running the service as the apache user: sudo -u www-data java -jar start.jar
This example configuration may be sufficient in some cases, while in others it may be more appropriate to configure Solr to run in Tomcat or another application server. If the simple example implementation is acceptable, it can be made into an init service by creating an executable script at /etc/init.d/solr similar to the following:
#!/bin/sh # Prerequisites: # 1. Solr needs to be installed at /usr/local/solr/example # 2. daemon needs to be installed # 3. Script needs to be executed by root # This script will launch Solr in a mode that will automatically respawn if it # crashes. Output will be sent to /var/log/solr/solr.log. A PID file will be # created in the standard location. start () { echo -n "Starting solr..." # Start daemon daemon --user=www-data --chdir='/usr/local/solr/example' --command "java -jar start.jar" --respawn --output=/var/log/solr/solr.log --name=solr --verbose RETVAL=$? if [ $RETVAL = 0 ] then echo "done." else echo "failed. See error code for more information." fi return $RETVAL } stop () { # Stop daemon echo -n "Stopping solr..." daemon --stop --name=solr --verbose RETVAL=$? if [ $RETVAL = 0 ] then echo "Done." else echo "Failed. See error code for more information." fi return $RETVAL } restart () { daemon --restart --name=solr --verbose } status () { # Report on the status of the daemon daemon --running --verbose --name=solr return $? } case "$1" in start) start ;; status) status ;; stop) stop ;; restart) restart ;; *) echo $"Usage: solr {start|status|stop|restart}" exit 3 ;; esac exit $RETVAL
This script can then be enabled on a debian system with: update-rc.d solr defaults
On a redhat system: /usr/sbin/chkconfig --add solr
Configure Solr Integration
The Solr admin interface should now be available at: http://localhost:8983/solr/admin/
If so, enable the "Apache Solr framework" and "Apache Solr search" modules in Drupal. There should now be an Apache Solr search menu item in administration under Site Configuration. That page gives the current status of the index and replaces core Drupal indexing. The Indexing throttle on the core Search settings page should be set to zero to disable it. If the Solr index status shows zero items indexed and zero remaining, try clicking the button to Queue all content for reindexing. Actions can then be taken to begin indexing or it can be handled in the background via cron.
Check other settings for Apache Solr search as appropriate. By default, the new search functionality will be available at the /search/site path of the website.