当前位置: 动力学知识库 > 问答 > 编程问答 >

java - Creating collections in SOLR

问题描述:

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);
}
分享给朋友:
您可能感兴趣的文章:
随机阅读: