Apache Solr is a proven and popular open source search platform developed by Apache Lucene. It is an application developed in java and runs as a standalone full text search server embedded in a servlet container. Solr search is server-independent and supports the following features:
Multi Site Search: Multiple search sites can be performed when the large number of websites have a common index. The shared index of these sites stores the documents with a site and a hash field which enables to filter by keywords and generate the results either from a single site or the sites that share the index. There is Apache Solr Multisite Search Module which adds the tab "Multisite search" to the search page.
Distributed Search: Takes place either when the length of the index exceeds the capacity of a single system or when the execution of a query takes a long time and splits the data into different parts. Solr can query and join the split results.
Faceted Search: This technique is used to minimize the search result according to the categories and get the relevant information. The end users are able to extract adequate information in several ways to meet their needs e.g. in a retail website, when a product is searched, the users get additional options to narrow search result in the left hand side. These options make the search more accurate and specific.
Solr also has an edge over drupal core search with respect to indexing and scalability.
Tomcat and Solr are dependent on Java Development Kit(JDK) and run on Java Virtual Machine (JVM). JDK consists of JVM and Java Runtime Environment (JRE). Therefore, we need to install full JDK.
aptitude install java7-jdk
Apache Tomcat is another open source web server consisting servlet container. It enables us to view and run jsp and servlets in the browser. Apache Tomcat consists of configuration and management tools. However, it can be configured by editing XML configuration files. Tomcat 7 runs on Servlet 3.0 and JSP 2.2 specification. It requires Java Development Kit (JDK 1.6) and later version.
Installing Tomcat 7
- Add a user and associated permission
useradd -Mb /usr/local tomcat chown -R tomcat:tomcat /usr/local/tomcat
- Get the Tomcat’s latest version from http://tomcat.apache.org/download-70.cgi and download the file tar.gz binary to usr/local/src server and extract the file to usr/local/tomcat
wget http://apache.tradebit.com/pub/tomcat/tomcat-7/v7.0.53/bin/apache-tomcat-7.0.53.tar.gz tar -C /usr/local -zxf /usr/local/src/apache-tomcat-7.*.tar.gz mv /usr/local/apache-tomcat-7.* /usr/local/tomcat
- The default HTTP connector port and AJP connector port is 8080 and 8009 respectively. We had varnish installed on port 80 & Apache running on 8080. To avoid, we have to change port number Tomcat listens to. Command line to find & replace port number -
sed -i s/8080/8983/g /usr/local/tomcat/conf/server.xml // You can give any non conflicting port number
- Test the successful installation of Apache Tomcat
sudo -u tomcat /usr/local/tomcat/bin/startup.sh
You are good to go if you don’t see any errors on your termial.
Solr Installation steps
- Download Solr 4.7 from http://lucene.apache.org/solr/ and extract the downloaded file
cd /usr/local/src wget http://apache.tradebit.com/pub/lucene/solr/4.7.2/solr-4.7.2.tgz tar -zxf solr-4.7.2.tgz
- Copy the Solr java library files from Solr to Tomcat library directory
cp solr-4.7.2/dist/solrj-lib/* /usr/local/tomcat/lib/
- Copy log4j configuration file from Solr to Tomcat config directory
cp solr-4.7.2/example/resources/log4j.properties /usr/local/tomcat/conf/
- Install Apache Solr’s war into Tomcat Webapps directory
cp solr-4.7.2/dist/solr-4.7.0.war /usr/local/tomcat/webapps/solr.war
- Add Solr context file in /usr/local/tomcat/conf/Catalina/localhost/solr.xml and add the following code
Solr Configuration with Drupal
- Create the Solr directory and copy the example Solr configuration
mkdir -p /usr/local/tomcat/solr cp -r solr-4.7.2/example/solr/collection1/conf /usr/local/tomcat/solr/
- Get the latest version of Search API Solr Search from Drupal ( Apache Solr Drupal module didn’t worked with Solr 4.7.2 though it used to work with Solr 4.4 )
cd /usr/local/src wget http://ftp.drupal.org/files/projects/search_api_solr-7.x-1.4.tar.gz tar -zxf search_api_solr-*.tar.gz
- Copy Solr configuration files from Search API Solr Searchl module to Tomcat configuration directory
rsync -av search_api_solr/solr-conf/4.x/ /usr/local/tomcat/solr/conf/
- Create Apache Solr Drupal setting in the path /usr/local/tomcat/solr/solr.xml and paste the following to define valuebound core (you can have own name for the core)
<?xml version="1.0" encoding="UTF-8" ?>
- Make valuebound Solr core directory and copy Solr configuration files to new core
mkdir /usr/local/tomcat/solr/valuebound cp -r /usr/local/tomcat/solr/conf /usr/local/tomcat/solr/valuebound/
- Now just stop tomcat and assign the permission and check this
/usr/local/tomcat/bin/shutdown.sh chown -R tomcat:tomcat /usr/local/tomcat sudo -u tomcat /usr/local/tomcat/bin/startup.sh
Now you will test your new the valuebound Solr core admin interface in http://yourdomain.com:8983/solr/#/valuebound. But you should be using http://yourdomain.com:8983/solr/valuebound URL while configuring Drupal Apache Solr.
Now to start tomcat automatically every time you restart server -
Download this tomcat init script. Create init file for tomcat at /etc/init.d/tomcat and copy paste content of tomcat.txt.
Valuebound is a Drupal development company providing Apache Solr Implementation and integration with Drupal CMF. Contact us if you would like to use Apache Solr to improve search result for your Drupal driven web sites and applications..