Last updated 30 October 2013. Created on 8 June 2009.
Edited by Sutharsan, kb_0, xtfer, pwolanin. Log in to edit this page.

Setting up one Solr server with two or more Drupal sites takes some additional configuration. If this is not done, all of the data for each site goes into the same index and when searching on one site, results are returned from both sites. If that's not the desired result (faceting won't currently work correctly), then it is necessary to 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 1.4.1 from a mirror:
    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. For Drupal 6.x-1.x, download the Solr PHP Client library (http://code.google.com/p/solr-php-client/downloads/list) and unpack it so it is under the apachesolr module directory as SolrPhpClient (i.e. sites/all/modules/apachesolr/SolrPhpClient).
  4. Unpack the tarball OUTSIDE OF THE WEB ROOT.  This will create a folder called "apache-solr-1.4.1".
  5. Make a copy of the "example" directory found in the "apache-solr-1.4.1" directory; call it "drupal".
  6. Go to "apache-solr-1.4.1/drupal/solr/conf" and rename schema.xml and solrconfig.xml.  Add a .bak to the end or something.
  7. Go to where you unzipped the Solr Module.  Copy "schema.xml" and "solrconfig.xml" to "apache-solr-1.4.1/drupal/solr/conf"
  8. Delete the following directories.  They're just in the way:
    - example-DIH
    - exampleAnalysis
    - exampledocs
    - work
  9. Copy "drupal/multicore/solr.xml" to "drupal/solr/solr.xml" 
  10. Delete the "drupal/multicore" directory.
  11. 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
  12. 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.
  13. 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>
    
  14. Now fire up the Jetty servlet container from the command line in the "drupal" directory with: "java -jar start.jar"
  15. 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.
  16. 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!
  17. 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.  
  18. 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.
  19. 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.
  20. 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 the admin page will use a different path. The core name needs to be inserted in the path. For example the admin path for a core with the name "examplecore" would be
http://localhost:8983/solr/examplecore/admin/

Looking for support? Visit the Drupal.org forums, or join #drupal-support in IRC.

Comments

MickC’s picture

Thank for this solution, however I had to name the site the same as the site path to get it going.

e.g. <core name="anovasolutions" instanceDir="anovasolutions" />

Until then I could not reach the admin page, nor could connect from Drupal.
I of course renamed the actual directory to the same name as well.

monotaga’s picture

I ran into the same issue as MickC above. It'd be worth updating this page to reflect that the "name" and "instanceDir" appear to need to be the same.

Amit Dwivedi’s picture

Also worked gr8 with drupal 7.23 and solr 3.6

Yes its true, the name should be identical.

Consider the following as stated above in point no. 11.

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/anovasolutions (your first site name)
drupal/solr/myrandomideas (your second site name)

Same should be here: /drupal/solr/solr.xml (the file which is copied from multicore directory)

<solr persistent="false">
  <cores adminPath="/admin/cores">

   <core name="anovasolutions" instanceDir="anovasolutions" />
    <core name="myrandomideas" instanceDir="myrandomideas" />

  </cores>
</solr>

And for drupal 7 the setting path is:
http://your_site_name/admin/config/search/apachesolr/settings

And Solr Admin path is:
http://your_site_name:8983/solr/core_name/admin/ ( core name is stated in solr.xml file )

Hope this will help someone. :)

wonder95’s picture

There should also be a step for installing the Solr PHP Client library from here as mentioned in the apachesolr module handbook page.

aaronbauman’s picture

For me, there was no "apache-solr-nightly" directory anywhere on the system.
This presumably refers to the directory created by unpacking the apache solr tarball.
Mine was named "apache-solr-1.4.1"; presumably yours will be named according to the version number as well.

andosteinmetz’s picture

I've read a couple of places (here and in the README) that it's important to unpack the Solr tarball outside of the web root, so I've done that, but once it's unpacked should I move the Solr directory into the Drupal directory, or leave it outside of the web root? Thanks in advance!

Agileware’s picture

Leave it out.

Agileware
Australian Drupal, CiviCRM and Wordpress websites
https://agileware.com.au

vasrush’s picture

Does this tutorial works with the 6.2.x version of apache solr module?

mermentau’s picture

The ideas expressed here also work for me using Apache Solr Search Integration 7.x-1.x-dev and Apache Solr 3.6. The reading of the paths were a little different, but the basic idea works like a charm.

ressa’s picture

Copy original solr core, called "drupal" into new core "drupal2"
sudo cp -rp /usr/local/tomcat/solr/drupal /usr/local/tomcat/solr/drupal2

Add new core "drupal2" in solr.xml
sudo vi /usr/local/tomcat/solr/solr.xml

<?xml version="1.0" encoding="UTF-8" ?>
<solr persistent="false">
  <cores adminPath="/admin/cores">
    <core name="drupal" instanceDir="drupal" />
    <core name="drupal2" instanceDir="drupal2" />
  </cores>
</solr>

Restart solr

sudo -u tomcat /usr/local/tomcat/bin/shutdown.sh
sudo -u tomcat /usr/local/tomcat/bin/startup.sh

Try Drupal 8 at simplytest.me
FJ23’s picture

Is it possible to run Drupal 6 and 7 on the same solr 1.4.1 instance?

Thanks

ishwar’s picture

Hi I have started multicore setup with solr 4.x for drupal 7 .... but it unable to setup properly. Once I open solr url with my core setup it says "page not found". and I have checked solr log but it is not logging any Waring or Error message.

I unable to find out what is the problem behind it and what I am missing.

Is there any solution for the same...???

Thanks