简体   繁体   English

在SOLR中创建集合

[英]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. 在网上搜索SOLR中的集合时,我发现只有有关分布式搜索的信息等等,但是当我理解correclty集合的概念使用相同的模式在同一服务器实例上运行但在逻辑上完全分离。 Is this correct? 这个对吗? So I can have 3 collections and searching on one collection won´t output results of another right? 所以我可以有3个集合,搜索一个集合不会输出另一个集合的结果吗? 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 在我的solr.xml中我有

  <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? instanceDir是关于什么的? Is it the index-directory relative to SOLR-Home? 它是相对于SOLR-Home的索引目录吗?

You can use multiple cores. 您可以使用多个核心。 Each core is a separate lucene index. 每个核心都是一个单独的lucene索引。
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. instanceDir是该特定核心的配置文件的位置,该文​​件夹包含conf目录,其中包含schema.xmlsolrconfig.xml等。 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. 每个核心通常都有一个子文件夹,其中solr.xml是(SOLR_HOME),并使用相对路径在solr.xml本身中引用它们。

For more information on setting up cores and how they work, please see the Solr Wiki - CoreAdmin for more details and some examples. 有关设置内核及其工作方式的更多信息,请参阅Solr Wiki - CoreAdmin以获取更多详细信息和一些示例。

Your example for adding the second core-entry is sufficient. 您添加第二个核心条目的示例就足够了。

The instance directory is the index-directory relative to your SOLR home value. 实例目录是相对于SOLR主目录值的索引目录。

In addition to the REST API, you can create a new core using SolrJ. 除REST API之外,您还可以使用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 使用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). 幸运的是,现在有一个标准选项create脚本bin/solr ,它能够检测Solr在哪种模式下运行(独立或SolrCloud),然后采取适当的操作(创建核心或创建集合)。

$ 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: 例如,假设您在端口8983上运行最新版本的Solr,请创建一个刚运行的新核心:

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). 从客户端的角度来看,没有区别,因此创建核心或集合取决于Solr是以独立(核心)还是SolrCloud模式(集合)运行。

For a more complete distinction referer to Solr Collection vs Cores 有关Solr Collection vs Cores的更完整的区别引用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM