SolrJ and Auto Commit

♀尐吖头ヾ 提交于 2019-12-10 14:53:56

问题


I am adding documents to a Solr 4.3 core using SolrJ API , I noticed that I have the autocommit set to 15 seconds in the stock solrconfig that I am using as below.

 <autoCommit>
   <maxTime>${solr.autoCommit.maxTime:15000}</maxTime>
   <openSearcher>false</openSearcher>
 </autoCommit>

My undestanding is that since the auto commit is set to true it means that the Solr instance would be auto commiting anyhow every 15 seconds, so I would not need to commit explicity using the SolrJ API as in below everytime I add a document to Solr , is my understanding correct ?

        httpSolrServer.add(doc1);
        httpSolrServer.commit();// Is this still needed ?

Thanks in advance!


回答1:


If you have auto-commit defined, you don't need an explicit commit.

However, in your definition above, you have openSearcher set to false for the (hard) commit. Which means, Solr will commit but will not show the changes.

In the example configuration it works because there is also autoSoftCommit commit with openSearcher set to true (or true by default). That will make changes actually show but without doing expensive hard commit.

Together those two sections work well with you seeing the results fast and then periodically also saving everything to disk. But make sure you have both sections or you reopen the searcher in the one above. Doing only one out of two will cause the results to never show unless you also do explicit commit somewhere else.



来源:https://stackoverflow.com/questions/22293812/solrj-and-auto-commit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!