When should we apply Hard commit and Soft commit in SOLR?

早过忘川 提交于 2020-01-11 09:32:04

问题


I want to know when we should do hard commit and when we should do soft commit in SOLR.

Thanks


回答1:


In the same vein as the question you just asked but deleted, this is explained thoroughly on the internet:

Soft commit when you want something to be made available as soon as possible without waiting for it to be written to disk. Hard commit when you want make sure its being persisted to disk.

From the link above:

Soft commits

Soft commits are about visibility, hard commits are about durability. The thing to understand most about soft commits are that they will make documents visible, but at some cost. In particular the “top level” caches, which include what you configure in solrconfig.xml (filterCache, queryResultCache, etc) will be invalidated! Autowarming will be performed on your top level caches (e.g. filterCache, queryResultCache), and any newSearcher queries will be executed. Also, the FieldValueCache is invalidated, so facet queries will have to wait until the cache is refreshed. With very frequent soft commits it’s often the case that your top-level caches are little used and may, in some cases, be eliminated. However, “segment level caches”, used for function queries, sorting, etc., are “per segment”, so will not be invalidated on soft commit; they can continue to be used.

Hard commits

Hard commits are about durability, soft commits are about visibility. There are really two flavors here, openSearcher=true and openSearcher=false. First we’ll talk about what happens in both cases. If openSearcher=true or openSearcher=false, the following consequences are most important:

  • The tlog is truncated: A new tlog is started.
  • Old tlogs will be deleted if there are more than 100 documents in newer, closed tlogs.
  • The current index segment is closed and flushed.
  • Background segment merges may be initiated.
  • The above happens on all hard commits.

That leaves the openSearcher setting

  • openSearcher=true: The Solr/Lucene searchers are re-opened and all caches are invalidated. Autowarming is done etc. This used to be the only way you could see newly-added documents.
  • openSearcher=false: Nothing further happens other than the four points above. To search the docs, a soft commit is necessary.


来源:https://stackoverflow.com/questions/45998804/when-should-we-apply-hard-commit-and-soft-commit-in-solr

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