Creating Collections in SOLR

In the web search for collections in SOLR, I found only information about distributed searches, etc., but when I understand that the concept of matching collections runs on the same server instance using the same scheme, but is logically completely separate. It's right? So, I have 3 collections and a search in one collection will not lead to the results of another right? Can I search multiple collections at the same time?

But my main priority: how to create a second collection? Even a link to a good document will 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> 

Is it enough to create a second kernel entry and set different paths? as...

  <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 instanceDir? Is this an index directory relative to SOLR-Home?

+4
source share
4 answers

For more information on configuring kernels and how they work, see the Solr Wiki - CoreAdmin for more information and some examples.

Enough of your example to add a second master record.

The instance directory is an index directory relative to your original SOLR value.

+2
source

You can use multiple cores. Each core is a separate lucene index.
instanceDir is the location of the configuration files for this particular kernel, the folder that contains the conf directory, which contains schema.xml and solrconfig.xml among others. Usually you have a subfolder in the kernel where solr.xml (SOLR_HOME) and uses relative paths to reference them inside solr.xml itself.

+6
source

In addition to the REST API, you can create a new kernel using SolrJ. After I tried to create it myself, here is what I did:

 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); } 
+1
source

Tested with Solr 6.x

Fortunately, there is now a standard create option from script bin/solr that can detect in which mode Solr is running (stand-alone or SolrCloud), and then take appropriate action (create a kernel or create a collection).

 $ bin/solr create -help Usage: solr create [-c name] [-d confdir] [-n configName] [-shards #] [-replicationFactor #] [-p port] 

For example, if you are using the latest version of Solr on port 8983 , create a newly launched kernel:

 bin/solr create -c collection1 -d /path/to/solr/conf 

An important distinction must be made for the confusion that sometimes arises between collections and cores. From the point of view of the client, there are no differences, so the creation of a kernel or collection depends on whether Solr is working offline (core) or SolrCloud (collection).

For a more complete description of the abstract Solr Collection vs Cores

0
source

Source: https://habr.com/ru/post/1442060/


All Articles