How to create new collection in Solr

A collection or a core in Solr's terminology is a collection of indexed documents.

Strictly speaking, this post is about how to create core in Solr, since we don't involve distributed search, the core and collection can be used interchangeably here. Solr core and collection What's the difference

The Solr distribution package contains an example collection under example\solr\collection1.

Collection has its own schema, configuration and index data directory.

When you have different kinds of data need to be searched separately, you will need different collection to describe and store index for the data.

You may have a collection to index web pages and another collection to index PDF documents. For some special requirements, you may want to put index in a different collection.

To make it simple, you can create new collection base on the example collection.

Create a directory in example\solr, for example pagecollection, then create conf and data directory in pagecollection. Copy the content of example\solr\collection1\conf to new conf directory. You can tweak configurations later.

Add core configuration in example\solr\solr.xml like this.

<solr persistent="true">
  <cores adminPath="/admin/cores" defaultCoreName="collection1" host="${host:}" hostPort="${jetty.port:}" hostContext="${hostContext:}" zkClientTimeout="${zkClientTimeout:15000}">
    <core name="collection1" instanceDir="collection1" />
    <core name="pagecollection" instanceDir="pagecollection" />

Then start jetty server

java -jar start.jar

Then open browser and goto url .


You will see the collection in Core Selector:

solr new collection

How to create new collection in Solr 6

In Solr 6 we have new command line to help us create new collections

To create a new collection named demo2, go to bin folder and execute

C:\App\solr-6.3.0\bin>solr create -c demo2 -n democonf -p 8983
Copying configuration to new core instance directory:
Creating new core 'demo2' using command:

Your solr-6.3.0\server\solr folder should no contains folder with the same name.

Add document and query to the collection

curl http://localhost:8983/solr/demo2/update -d "[ {\"id\" : \"book1\",  \"title_t\" : \"Solr In Action\",  \"author_s\" : \"Timothy Potter\" }]"
curl http://localhost:8983/solr/demo2/get?id=book1

One more thing to notice, the command above won't commit the index, so you can not see it in Solr Web panel. To commit it add the commit parameter and set it to true

curl http://localhost:8983/solr/demo2/update?commit=true -d "[ {\"id\" : \"book1\",  \"title_t\" : \"Solr In Action\",  \"author_s\" : \"Timothy Potter\" }]"

Create a core with config set

Solr provides several configurations called config set you can use to create your core.

First start Solr server with the command

C:\App\solr-6.3.0\bin>solr start -p 8984
WARNING: 32-bit Java detected. Not recommended for production. Point your JAVA_HOME to a 64-bit JDK
Waiting up to 30 to see Solr running on port 8984
Started Solr server on port 8984. Happy searching!

Then create the core with the basic_configs

C:\App\solr-6.3.0\bin>solr create -c basiccore -d basic_configs -p 8984
Copying configuration to new core instance directory:
Creating new core 'basiccore' using command:

Open the browser with url