On the web searching for collections in SOLR i found only information about distributed search and so on but when I understand the concept of correclty collections are running on the same server instance using the same schema but are logically completely separated. Is this correct?
So I can have 3 collections and searching on one collection won´t output results of another right? Would it be possible to search on more than one collection at once?
But my main priority: How do I create a second collection? Even a link to a good doc would be appreciated.
In my solr.xml i have
<cores adminPath="/admin/cores" defaultCoreName="web-collection" host="${host:}" hostPort="${jetty.port:}">
<core name="web-collection" instanceDir="." />
</cores>
Would it be sufficient to create a second core-entry and set different paths? like...
<cores adminPath="/admin/cores" defaultCoreName="web-collection" host="${host:}" hostPort="${jetty.port:}">
<core name="web-collection" instanceDir="web" />
<core name="test-collection" instanceDir="test" />
</cores>
What is the instanceDir about? Is it the index-directory relative to SOLR-Home?
For more information on setting up cores and how they work, please see the Solr Wiki - CoreAdmin for more details and some examples.
Your example for adding the second core-entry is sufficient.
The instance directory is the index-directory relative to your SOLR home value.
You can use multiple cores. Each core is a separate lucene index.
instanceDir
is the location of the configuration files for that specific core, the folder that contains the conf
directory, which contains schema.xml
and solrconfig.xml
among others. You usually have a subfolder per core where the solr.xml
is (SOLR_HOME) and use relative paths to refer to them within the solr.xml
itself.
In addition to the REST API, you can create a new core using SolrJ. After struggling to create one myself, here's what I ended up doing:
SolrServer aServer = new HttpSolrServer("http://127.0.0.1:8983/solr");
CoreAdminResponse aResponse = CoreAdminRequest.getStatus(collectionName, aServer);
if (aResponse.getCoreStatus(aNewInstance.getCollection()).size() < 1)
{
CoreAdminRequest.Create aCreateRequest = new CoreAdminRequest.Create();
aCreateRequest.setCoreName(collectionName);
aCreateRequest.setInstanceDir(collectionName);
aCreateRequest.process(aServer);
}
Tested with Solr 6.x
Fortunately, there is now a standard option create
of script bin/solr
that is able to detect in which mode Solr is running in (standalone or SolrCloud), and then take the appropriate action (create a core or create a collection).
$ bin/solr create -help
Usage: solr create [-c name] [-d confdir] [-n configName] [-shards #] [-replicationFactor #] [-p port]
For example, assuming that you're running a recent version of Solr on port 8983
, create a new core just running:
bin/solr create -c collection1 -d /path/to/solr/conf
An important distinction has to be done for the confusion that sometimes happens between Collections and Cores. From the client perspective there are no differences, so create a core or collection depend on whether Solr is running in standalone (core) or SolrCloud mode (collection).
For a more complete distinction referer to Solr Collection vs Cores