Install Apache Solr 5 and Drupal Search API on your laptop in minutes

×

Error message

  • Notice: Trying to access array offset on value of type int in element_children() (line 6429 of /home/flinkco/public_html/includes/common.inc).
  • Notice: Trying to access array offset on value of type int in element_children() (line 6429 of /home/flinkco/public_html/includes/common.inc).
  • Notice: Trying to access array offset on value of type int in element_children() (line 6429 of /home/flinkco/public_html/includes/common.inc).
  • Notice: Trying to access array offset on value of type int in element_children() (line 6429 of /home/flinkco/public_html/includes/common.inc).
  • Notice: Trying to access array offset on value of type int in element_children() (line 6429 of /home/flinkco/public_html/includes/common.inc).
  • Deprecated function: The each() function is deprecated. This message will be suppressed on further calls in _menu_load_objects() (line 569 of /home/flinkco/public_html/includes/menu.inc).
  • Deprecated function: implode(): Passing glue string after array is deprecated. Swap the parameters in drupal_get_feeds() (line 394 of /home/flinkco/public_html/includes/common.inc).
Solr core Admin page, creating a Drupal Search core

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

4) A quick smoke test is to launch Solr in standalone (as opposed to cloud) mode
$ bin/solr start

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
$ cp -r [DocumentRoot]/sites/all/modules/search_api_solr/solr-conf/5.x server/solr/drupal-search/conf

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:

Drupal Search API configuration

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.

Drupal Search API configuration

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.

Drupal Search API configuration

8) Made a mistake? You can delete your Solr core like so:
$ bin/solr delete -c drupal-search

Then try again from step 5) or 6).

* * *

File under: 

Drupal 8: contrib roads, take me home

Read More »

Comments

If you familiar with Docker, then you could work with Solr much more easier. For example, here is my Solr 5.x Docker image on Docker hub: https://hub.docker.com/r/mxr576/apachesolr-5.x-drupal-docker/

Thanks Dezső

Can you elaborate on the "much more easier" part? To me, the instructions from this article actually look easier than the page you linked to (even more so if you haven't installed Docker yet). I know Docker containers solve other problems, but why do you consider it easier?

This is the best tutorial. Simple and useful! Thanks a lot! I just read 5 articles and none of them is clear and always lack of important details.

Add new comment