solrj solrclient.add集合顺序

时间:2016-07-08 22:29:54

标签: java solr solrj

我正在创建一个SolrInputDocuments列表,其中包含要在Solr 6中索引的原子更新(没有SolrCloud,没有Shards,只有一个Solr核心)。

如果我提供文件将如何编入索引并提交给Solr,是否存在订单差异:

一个。这个集合直接到客户端的add方法或

湾如果我外部循环它们并与客户端单独添加它们?

直接添加集合:

final SolrClient solr = createMySolrClient() // custom method
List<SolrInputDocument> solrDocsToIndex = createMySolrDocs() // custom method
solr.add(solrDocsToIndex);
solr.commit();

通过外部循环添加:

final SolrClient solr = createMySolrClient() // custom method
List<SolrInputDocument> solrDocsToIndex = createMySolrDocs() // custom method
for (SolrInputDocument solrDocToIndex : solrDocsToIndex) {
    solr.add(solrDocToIndex);
}
solr.commit();

在我的用例中,这些文档存储在列表中的顺序需要是Solr处理原子更新的顺序。

如上所示,可以直接将集合添加到add方法中吗?

1 个答案:

答案 0 :(得分:0)

如果您检查代码here,您可以看到上述代码调用UpdateRequest.add(Collection docs),其集合周期的提供方式与您在第二个用例中提到的方式相同。因此,订单将在两个建议的用例中得到维护。