Saturday 10 September 2016

How to create multiple indexes in SOLR?

For multiple Indexes, either we need to use multiple SOLRs in different ports or collections/cores.

Multiple SOLR ports can be achieved as follows, we need to have multiple copies of example folder with different port number, port number can be updated in jetty.xml file under example\etc folder. So, we can access two instances separately as http://localhost:8080/solr/#/ (port number : 8080) and http://localhost:8983/solr/#/ (port number : 8983).
For multicore, we have a folder named "multicore" inside example folder. We can see core0 and core1 folders by default. These folders will have separate schema and solrconfig files. Similarly, we have have multiple cores here. The multicore folder will have a solr.xml file. Need to mention each core in this file under <cores> as follows:

<core name="core0" instanceDir="core0" />
<core name="core1" instanceDir="core1" />
<core name="core2" instanceDir="core2" />

Here, instanceDir refers to the folder name and name refers to the path. Now, need to mention the solr home while starting the solr to make multicore as home. The command is as follows:

java -Dsolr.solr.home=multicore -jar start.jar

For multiple collections, create collections(copy the existing and paste) under example\solr with changing the core.properties file, need to mention the current collection name in core.properties file (update the file to text format, place the value, update the file format to txt).

Now, we can start solr without mentioning the solr home, command is java -jar start.jar

No comments:

Post a Comment

Your comment is so valuable as it would help me in my growth of knowledge.