In this tutorial, I will guide you through the process of configuring your Apache Solr to run with multiple cores. This can be useful if you are using Apache Solr with multiple different projects, and need complete separation between the two projects' search indexes.
This tutorial assumes that you are running Apache Solr on Jetty Web Server, and have both set up in the same manner as described in the following tutorials:
How to Install Jetty Web Server in Ubuntu
How to Install Apache Solr in Ubuntu
Edit solr.xml
cd /opt/jetty/solr sudo gedit solr.xml
If you haven't done any modifications to your current solr.xml file, then use the following as a template:
The import parts of this file are the core tags.
Create Cores Directory
Create a new directory within the solr directory to keep all the cores organized:
cd /opt/jetty/solr sudo mkdir cores
Configure First Core
We're going to use the default core that ships with Apache Solr 4 as our template:
cd /opt/jetty/solr sudo cp -R collection1 ./cores/core0
Create a data directory for this core:
cd /opt/jetty/solr/cores/core0 sudo mkdir data
Now edit the solrconfig.xml for this core:
cd /opt/jetty/solr/cores/core0/conf sudo vim solrconfig.xml
Change the following:
${solr.data.dir:}
To:
/opt/jetty/solr/cores/core0/data
And, change the following:
${solr.data.dir:}
To:
/opt/jetty/solr/cores/core0/data
Create Second Core
Copy the first core:
cd /opt/jetty/solr/cores sudo cp -R core0 core1
Now edit the solrconfig.xml for this core:
cd /opt/jetty/solr/cores/core1/conf sudo vim solrconfig.xml
Change the following:
${solr.data.dir:}
To:
/opt/jetty/solr/cores/core1/data
And, change the following:
${solr.data.dir:}
To:
/opt/jetty/solr/cores/core1/data
Set Owner of Cores Directory
Finally, you'll need to set Jetty as the owner of the cores directory:
cd /opt/jetty/solr sudo chown -R jetty:jetty cores
Restart Jetty
sudo /etc/init.d/jetty restart
If all is well, you should be able to access the admin page for each core at the following URLs:
The query URL works similarly: