Drupal Apache Solr Search: Multi Site (Instance) Setup

Hey, I noticed this page gets lots of traffic off the search engines. If you need help feel free to drop me a line. chrisrikli + this domain name.

- Chris 09/12/2011

Here is an updated guide that walks through setting up Solr for Multi-site using Tomcat. This is a superior solution to using Jetty as it's a bit more secure.

Be sure to read my comment about the potential need to get permissions set properly on *nix.

- Chris, 07/25/2011

Ok.  So I ran into a little issue when I tried to run two Solr site searches at the same time.  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. 

Not good.  And there is almost nothing out there to tell you how to deal with this issue, aside from posts on *.drupal.org telling you that the module itself isn't ready to deal with the issue.

So here's how you get it done.  I'm running Windows XP so the paths might look a bit different for you folks using Linux or Mac servers, but this should work.  All of the breadcrumbs I found during my search to do this were for *nix anyway.

I'm going to assume that you already have a single-site instance of Solr for Drupal running.  If you do not, follow the instruction here but STOP after #5 (right where it says "STOP").

We'll pick up here:

 

  1. Make a copy of the "example" directory found in the "apache-solr-nightly" directory; call it "drupal_multisite".
  2. Delete the following directories.  They're just in the way:
    - example-DIH
    - exampleAnalysis
    - exampledocs
    - work
  3. Copy "drupal_multisite/multicore/solr.xml" to "drupal_multisite/solr/solr.xml" 
  4. Delete the "drupal_multisite/multicore" directory.
  5. Now create directories within the "drupal_multisite/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_multisite/solr/site_anovasolutions
    drupal_multisite/solr/site_myrandomideas
  6. Copy the "drupal_multisite/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.
  7. Delete the "drupal_multisite/conf" directory.
  8. Now alter the solr.xml file you copied over in step 3 to accommodate both site.  So my 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>
  9. Now fire up the .jar from the command line with: "java -jar start.jar"
  10. Activate the Solr modules like I talked about in step 7 here, but of course you'll do this for both sites.
  11. This is the key: follow the instructions for step 8 from here, but the Solr paths will be as follows for each site:
    /solr/anovasolutions (for anovasolutions.com)
    /solr/myrandomideas (for myrandomideas.com)
  12. You're ready to rock.  You'll need to index with the cron like I talked about in the other post.
I hope this helps someone.