How to add collections to solr core?

11,549

Solution 1

It's very easy, just copy/paste exist collection, and rename this copy, for instance collection2. Also do not forget edit core.properties file, put there new collection's name.

Solution 2

Core and Collection is basically the same where you would hold the information pertaining to different unrelated entities.

You would have different Cores/Collections for e.g. Documents, People, News etc...
You can always club information within the same Core/Collection e.g. Document & People etc.
It would really depend on how you index your data and what the requirements are.

You need to check Solr Multicore feature, which allows you to setup multiple cores/collections

You can find multiple blogs about Multicore setup

You can download the book from LucidWorks as well for more detailed information

Solution 3

if your one collection is present inside example/solr directory, then you can create another collection inside the same example/solr directory. Do note that it is not strictly multicore since all the collections are present inside the same core and so all the collections will share the same solr.war file. The collections directory would have their own subdirectories :- conf and data. Also, each collection should have its own schema.xml and solrconfig.xml

for example, assume you have two collections :- collection1 and collection2 inside example/solr directory. Then you can call them by :-

http://localhost:8983/solr/collection1/select?parameters

http://localhost:8983/solr/collection2/select?parameters

once you have created all the collections, you will have to modify the solr.xml file in example/solr directory. Look to the core child tag in cores name xml tag and add the new collection there.

<core name="collection1" instanceDir="collection1" />
<core name="collection2" instanceDir="collection2" />

The instanceDirs are the name of the directories in which your cores are present.

Solution 4

The best way is to create it from console with:

solr create -с collection2

In linux you should run it from solr user

sudo su - solr -c "/opt/solr/bin/solr create -c collection2"
Share:
11,549
Manojak
Author by

Manojak

Updated on June 04, 2022

Comments

  • Manojak
    Manojak almost 2 years

    I want to add one more collection to solr core. I need blogs for examples and suggestions.

    I am using Tomcat 7 and Ubuntu for this.

    Though it is mentioned in the wikies about how to install Solr and create cores, there's no complete view about how to create collection under the same core.

    How to add Solr collection in this case?

  • Andrei Diaconescu
    Andrei Diaconescu about 11 years
    can you please say how to create a new collection . you say "once you have created all the collections" but the problem is just that: how to create a new collection. Do i need to duplicate the folder of collection1 and rename it to collection2 ?
  • Max
    Max about 11 years
    yup. that is it. copy the collection1 directory and rename it to collection2. each collection will have its own schema and solrconfig file. Once that is setup, then edit your solr.xml.
  • Sergey
    Sergey almost 9 years
    Copy-paste from where to where?