Install Apache Solr 5 and Drupal Search API on your laptop in minutes
We recently had to debug a site for a customer who was using Apache Solr and that wonderful Drupal module combo that goes with it: Search API and Search API Solr.
Replicating the site locally, so it was easier and more efficient to work with and debug, we were pleased to find that these components have continued to evolve over the past years, much to the benefit of their users . Setting up Apache Solr for Drupal is now easier than ever before, whether you use the command line or the newish Solr user interface.
In the steps below we've gone mostly for the point and click install.
1) On the Solr site, hit the download button. This redirects you to a page with a number of mirror sites from which you can download the .tgz. Or the .zip if you prefer.
2) Once downloaded unzip the .tgz or .zip and move it to your favourite application folder. I have fallen into the habit of abusing /Applications for this on my Mac, but you can use almost any folder that works for you.
3) Now cd into the epicentre of your Solr installation. When reading further documentation this is where it is assumed that you execute your Solr commands from: $ cd /Applications/solr-5.2.1<br>
4) A quick smoke test is to launch Solr in standalone (as opposed to cloud) mode $ bin/solr start<br>
Waiting to see Solr listening on port 8983 [/]
Started Solr server on port 8983 (pid=10162). Happy searching!
Yay! Our Solr is up and running!
5) Let’s hook it up to Drupal by giving it a Search API configuration to work with. In your solr-5.2.1/server/solr directory create a new directory drupal-search and inside that a directory conf. Then drag all the files residing in /sites/all/modules/search_api_solr/solr-conf/5.x into drupal-search/conf.
Or using the command line:$ mkdir server/solr/drupal-search<br> $ cp -r [DocumentRoot]]/sites/all/modules/search_api_solr/solr-conf/5.x server/solr/drupal-search/conf<br>
6a) Now open a browser window and visit localhost:8983/solr and click the No cores available — Go and create one menu option in the bottom left. Enter "drupal-search" in the first two text boxes and press "Add Core". See the screenshot at the top of this article.
6b) Verify by picking "drupal-search" in the core selector drop-down. You should see something like this:
No errors? Great!
7) Revisit your Drupal site on the Search API config page, at admin/config/search/search_api and fill it out as shown below.
Press "Save settings" and you should see lots of green, like the screenshot below.
Check and tweak the configuration if necessary via the Edit tab at the top.
8) Made a mistake? You can delete your Solr core like so: $ bin/solr delete -c drupal-search<br>
Then try again from step 5) or 6).
* * *
File under: Planet Drupal