Solr is a standalone enterprise search server with a REST-like API. It is a Java-based application that provides an API for interacting with Apache Lucene via HTTP to facilitate the creation of excellent applications for performing full-text content searches, with a special focus on internet-based search applications.
- Powerful Extensions
- Faceted Search and Filtering
- Advanced Configurable Text Analysis
- Performance Optimization
- Advanced Storage Options
It becomes an obvious choice because compared to Drupal’s default modules, it’s insanely fast. It helps you improve both speed and relevancy of search result for Drupal site. I will now present a step-by-step guide on how to install necessary tools and integrate Solr with Drupal 7.
-2. Install Java on Ubuntu with Apt-Get
First, update the package index:
sudo apt-get update
Then, check if Java is not already installed:
If it returns "The program java can be found in the following packages", Java hasn't been installed yet, so execute the following command:
sudo apt-get install default-jre
This will install the Java Runtime Environment (JRE). If you instead need the Java Development Kit (JDK), which is usually needed to compile Java applications (for example Apache Ant, Apache Maven, Eclipse and IntelliJ IDEA execute the following command:
sudo apt-get install default-jdk
-1. Install Solr using apt-get (easy way) on Ubuntu 14.04
sudo apt-get -y install openjdk-7-jdk
ln -s /usr/lib/jvm/java-7-openjdk-amd64 /usr/java/default
We can now start the real installation of Solr. First, download all files and uncompress them:
tar -xvf solr-4.7.2.tgz
cp -R solr-4.7.2/example /opt/solr
java -jar start.jar
Check if it works by visiting http://YOUR_IP:8983/solr
0. How to setup Search API with Apache Solr
Setup Search API
To get Search API working with solr there are a few thing we'll have to configure with solr. First go and download the following modules from drupal.org and place them into sites/all/modules:
- Search API
- Search API Solr search
drush dl entity search_api search_api_solr
Copy the schema.xml and solrconfig.xml that ships in search_api_solr and paste it into /solr/conf. It's fine to override the existing xml files just make sure you create a backup.
Now go ahead and test solr with the new xml files.
java -jar start.jar
Go to see if solr is working with the new XML files.
Go here and download (Only works with r22 Solr PHP Client (Built 11/09/09 from r22) ) the php solr library and place it in the seach_api_solr directory.
Go to the modules page and enable the Search API, Search pages and Solr search.
Configure Search API
Go to Configuration >> Search and metadata and click on Search API.
There are three steps involved with setting up a solr search page. First we setup the server, then index and finally the search page.
From the Search API configuration page click on the Add server link.
Enter in the Server name and Server description then select Solr service from the Service class select box.
Adjust the Solr service details below if you have any specific requirements.
Once you have finished filling out the form click on Save settings.
Once the server has been setup, the next thing we have to do is configure the index. Click on the Add index from the Search API configuration page.
In the Add index form fill out the Index name and select which entity type you want to index and select Solr from the Server select box.
Once you have created the index you'll have to select which fields will get indexed. This could take some trial and error depending on your data. In the example that I'm using I have add the "main body text" and "Tags" from the Add related fields.
After you have selected which fields get to be indexed, you'll be directed to the Workflow page. On this page you can specify extra data alterations and processors to the index data. For this example we'll keep that page empty.
The final item for the index is to actually add data into the solr index. Click on the Status tab and click on the Index now button.
1. Faceted Search
Another great feature that the Search API gives you is faceted search.
To get started go and enable the Search facets module.
Once the module has been enabled go back and edit the index that you created. Then select Facets from the dropdown.
For this example I enabled the Content type and Tags > Name block. But you can select any facet blocks.
Once the blocks are enabled don't forget to assign them to a region.
Go back to your search page and test out the facets.
Stay connected with for more technical Blogs coming on the way!