Apache Solr Multi-core Setup

Last modified: November 12, 2009 - 04:00

You will run into issues if you try to use the same Solr server with two or more Drupal sites. Basically, all of the data for each site goes into the same index and when you search on one site, you get content from the other. If that's not what you want (faceting won't currently work correctly), then you can set up a separate Solr core for each site. Each core is a totally independent search index.

These instructions are for Windows XP/Server 2K3 so the paths might look a bit different for folks using Linux or Mac servers, but this should work.

  1. Download Solr from a mirror:
    http://people.apache.org/builds/lucene/solr/nightly/
    http://www.apache.org/dyn/closer.cgi/lucene/solr/
  2. Download the Apache Solr Drupal module and unzip wherever you put your Drupal modules.
  3. Unpack the tarball OUTSIDE OF YOUR WEB ROOT.  You'll end up with a folder called "apache-solr-nightly".
  4. Make a copy of the "example" directory found in the "apache-solr-nightly" directory; call it "drupal".
  5. Go to "apache-solr-nightly/drupal/solr/conf" and rename schema.xml and solrconfig.xml.  Add a .bak to the end or something.
  6. Go to where you unzipped the Solr Module.  Copy "schema.xml" and "solrconfig.xml" to "apache-solr-nightly/drupal/solr/conf"
  7. Delete the following directories.  They're just in the way:
    - example-DIH
    - exampleAnalysis
    - exampledocs
    - work
  8. Copy "drupal/multicore/solr.xml" to "drupal/solr/solr.xml" 
  9. Delete the "drupal/multicore" directory.
  10. Now create directories within the "drupal/solr" directory for each site you want to use Solr with.  For example, if I had two sites "anovasolutions.com" and "myrandomideas.com" and I wanted to use Solr with them both, I might create the following directories:
    drupal/solr/site_anovasolutions
    drupal/solr/site_myrandomideas
  11. Copy the "drupal/solr/conf" directory into each directory you just created. When you're done each site's directory should have a copy of "conf" in them.
  12. Now alter the solr.xml file you copied over to list both sites.  So your solr.xml would look like this:
    <?xml version="1.0" encoding="UTF-8" ?>
    <solr persistent="false">
    <cores adminPath="/admin/cores">
      <core name="anovasolutions" instanceDir="site_anovasolutions" />
      <core name="myrandomideas" instanceDir="site_myrandomideas" />
    </cores>
    </solr>
  13. Now fire up the Jetty servlet container from the command line in the drupal directory with: "java -jar start.jar"
  14. Enable the "Apache Solr framework" and "Apache Solr search" modules. Also, enable the core Drupal Search module if you haven't already. Do this for both sites.
  15. Navigate to the Solr Settings page for each site (?q=admin/settings/apachesolr/settings).
    - Solr host name: localhost
    - Solr port: 8983
    - Solr path for anovasoutions.com: /solr/anovasolutions
    - Solr path for myrandomideas.com: /solr/myrandomideas
    - Number of items to index per cron run: I always set this to 200.
    - Enable spellchecker and suggestions: Check that...it's sweet!
  16. Click "Save Configuration."  The first time around it'll probably tell you it can't reach the server, but if you refresh the page you'll be good to go.  
  17. Note that you're going to have to start Solr every time you reboot the machine.  Windows users, set up a scheduled task.  *nix/Mac users, follow these instructions.  There's a great walkthrough there as well.
  18. Check out admin/blocks.  You'll see a bunch of new blocks related to Solr.  I'd just activate all of these so you can get an idea of what you're dealing with.
  19. You're going to need to run cron until the entire site is indexed.  If you have a lot of content, this could take a while.

Adapted with permission from: http://www.anovasolutions.com/content/drupal-apache-solr-search-multi-si...

Note

After following these instructions (which are very usefull!) I found that the admin page had moved from it's default place... As a reminder to myself and a help to anybody in the future... You need to insert the "core name" in the path.. For example..
http://localhost:8983/solr/anovasolutions/admin

 
 

Drupal is a registered trademark of Dries Buytaert.