如何配置Solr以提高索引速度

问题描述 投票:13回答:2

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

solr solrj solr4
2个回答
11
投票

似乎您正在将数据大量导入Solr,因此您无需立即搜索任何数据。

首先,您可以增加每个请求的文档数量。由于您的文档很小,因此我甚至可以将每个请求的文档数量增加到10万或更多,然后尝试。

第二,您要减少批量索引时提交的次数。在您的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>

您可以完全禁用autoCommit,然后在发布所有文档后调用一次提交。否则,您可以如下调整数字:

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

此外,在完成批量导入后,请减少maxTimemaxDocs,以便您对Solr进行的任何增量张贴都将更快地得到落实。或使用solrconfig中提到的commitWithin


0
投票

除了上面写的以外,在使用SolrCloud时,您可能希望在使用SolrJ时考虑使用CloudSolrClientCloudSolrClient客户端类是Zookeeper感知的,并且在某些情况下可以直接连接到领导者碎片以加快索引编制速度。

© www.soinside.com 2019 - 2024. All rights reserved.