13

我有一个客户端程序,它生成 1-50 百万个 Solr 文档并将它们添加到 Solr。
我正在使用 ConcurrentUpdateSolrServer 从客户端推送文档,每个请求 1000 个文档。
文档相对较小(很少有小文本字段)。
我想提高索引速度。
我尝试将“ramBufferSizeMB”增加到 1G,将“mergeFactor”增加到 25,但没有看到任何变化。
我想知道是否还有其他推荐的设置来提高 Solr 索引速度。
任何指向相关材料的链接将不胜感激。

4

2 回答 2

12

看起来您正在将数据批量导入 Solr,因此您无需立即搜索任何数据。

首先,您可以增加每个请求的文档数量。由于您的文档很小,我什至会将每个请求增加到 100K 文档或更多并尝试。

其次,您希望减少批量索引时发生的提交次数。在您的 solrconfig.xml 中查找:

<!-- AutoCommit

     Perform a hard commit automatically under certain conditions.
     Instead of enabling autoCommit, consider using "commitWithin"
     when adding documents.

     http://wiki.apache.org/solr/UpdateXmlMessages

     maxDocs - Maximum number of documents to add since the last
               commit before automatically triggering a new commit.

     maxTime - Maximum amount of time in ms that is allowed to pass
               since a document was added before automatically
               triggering a new commit.

     openSearcher - if false, the commit causes recent index changes
     to be flushed to stable storage, but does not cause a new
     searcher to be opened to make those changes visible.
  -->
 <autoCommit>
   <maxTime>15000</maxTime>
   <openSearcher>false</openSearcher>
 </autoCommit>

您可以完全禁用自动提交,然后在发布所有文档后调用提交。否则,您可以按如下方式调整数字:

默认maxTime值为 15 秒,因此如果有未提交的文档,自动提交每 15 秒发生一次,因此您可以将其设置为较大的值,例如 3 小时(即 3*60*60*1000)。您还可以添加<maxDocs>50000000</maxDocs>,这意味着仅在添加 5000 万个文档后才会发生自动提交。发布所有文档后,手动或从 SolrJ 调用一次 commit - 提交需要一段时间,但总体上会快得多。

此外,在您完成批量导入后,减少maxTimemaxDocs,这样您将对 Solr 所做的任何增量帖子都会更快地提交。或者commitWithin按照 solrconfig 中的说明使用。

于 2013-03-28T00:46:53.213 回答
0

除了上面写的,在使用 SolrCloud 时,您可能需要考虑CloudSolrClient在使用 SolrJ 时使用。客户端类是 Zookeeper 感知的CloudSolrClient,并且能够直接连接到领导分片,在某些情况下加快索引速度。

于 2020-03-25T17:14:39.253 回答