Tuesday, May 29, 2012

New BitNami Apache Solr Stack

We are happy to announce a new member in the BitNami family: Apache Solr. It is an open source enterprise search platform from the Apache Lucene project. Major features include powerful full-text search, hit highlighting, faceted search, dynamic clustering, database integration, and rich document handling. Solr is written in Java and runs as a standalone full-text search server within a servlet container such as Jetty.

In this post, we walk you through configuring Drupal 7 with Solr in Amazon EC2. We will start with a BitNami Drupal image but these steps will also work for your own Drupal installation.

First, start two instances from the Amazon console, one with Drupal and one with Solr. You can search by name in the Community AMIs listings or you can start them directly from the BitNami Drupal and Solr pages. In this case, we will start an EBS image with Ubuntu 64 bit.

For the Solr instance, you must add a new rule to your security group. The default Solr port is 8983, so you should open it to connect the Drupal application with the Solr instance. If you know the IP address where the Drupal instance is running, you can enable connections only to that IP address.

Once the Solr and Drupal instances are running, you can check that both are running using the public domain names.

The BitNami Drupal Stack already has the Apache Solr Search Integration module installed, so you just need to enable the Solr Search and Access modules. If you do not have this module installed, you can install it from the Administration panel.

The BitNami Solr AMI ships an example already configured. To configure the Solr server properly for Drupal, copy the schema.xml and solrconfig.xml files from the Solr Search module. You can find these files in the "/opt/bitnami/apps/drupal/htdocs/sites/all/modules/apachesolr/solr-conf" folder in the Drupal instance. Copy these files into the "/opt/bitnami/apache-solr/solr/conf" directory and restart the Solr server.

$ sudo /opt/bitnami/ctlscript.sh restart solr

In the Solr admin panel, you should now see something like "drupal-3.0-beta16". If this is the case, everything is ready on the Solr side.

Now, we will configure the Drupal application. Click on the "Modules" -> "Solr Search Framework" configuration button and add a new connection:

URL: http://Solr_IP:8983/solr
Name: Remote Solr

Test the connection. If it is not able to contact the Solr server, check that the IP address is correct and the 8983 port is ready for connections. 

Now, configure the Drupal application to use Solr by default. Go to "Configuration" -> "Search settings" and enable Apache Solr search in the default search modules. If you have already content in your Drupal installation, you can re-index your site. This could take some time depending on your blog content. That's it! Test the setup by trying to use the search block in your site to see the results. 

You can find specific documentation for Drupal configuration with Solr here.