有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java Solr自动提交和自动优化?

我将很快将我的网站上传到VPS。这是一个分类广告网站,使用与MySql集成的Solr

每当放置或删除新分类时,Solr都会更新

我需要一种方法使commit()optimize()自动化,例如每3小时左右一次

我该怎么做?(详情请参阅) 什么时候进行优化比较理想

谢谢


共 (1) 个答案

  1. # 1 楼答案

    您可以设置一个cron任务,定期执行对Solr REST接口的远程调用,例如:

    curl 'http://<SOLR_INSTANCE_URL>/update?optimize=true'
    

    查找有关更新Solr索引here的更多信息

    引用Solr tutorial

    Commit can be an expensive operation so it's best to make many changes to an index in a batch and then send the commit command at the end. There is also an optimize command that does the same thing as commit, in addition to merging all index segments into a single segment, making it faster to search and causing any deleted documents to be removed.

    更新: 此外,可以在solrconfig中启用自动提交功能。xml(在UpdateHandler部分中):

    <autoCommit>
          <maxDocs>10000</maxDocs> <!  maximum uncommited docs before autocommit triggered  >
          <maxTime>86000</maxTime> <!  maximum time (in MS) after adding a doc before an autocommit is triggered  >
    </autoCommit>