原创 2013年12月05日 10:02:22


A commit operation makes index changes visible to new search requests. A hard commit also calls fsync on the index files to ensure they have been flushed to stable storage and no data loss will result from a power failure.

A soft commit is much faster since it only makes index changes visible and does not fsync index files or write a new index descriptor. If the JVM crashes or there is a loss of power, changes that occurred after the last hard commit will be lost. Search collections that have near-real-time requirements (that want index changes to be quickly visible to searches) will want to soft commit often but hard commit less frequently.

An optimize is like a hard commit except that it forces all of the index segments to be merged into a single segment first. Depending on the use cases, this operation should be performed infrequently (like nightly), if at all, since it is very expensive and involves reading and re-writing the entire index. Segments are normally merged over time anyway (as determined by the merge policy), and optimize just forces these merges to occur immediately.


  • <commit/>

Optional attributes for "commit" and "optimize"

  • waitFlush = "true" | "false" — default is true — block until index changes are flushed to disk <!> Solr1.4 At least in Solr 1.4 and later (perhaps earlier as well), this command has no affect. In <!> Solr4.0 it will be removed.

  • waitSearcher = "true" | "false" — default is true — block until a new searcher is opened and registered as the main query searcher, making the changes visible.

  • softCommit = "true" | "false" — default is false — perform a soft commit - this will refresh the 'view' of the index in a more performant manner, but without "on-disk" guarantees. <!> Solr4.0

Optional attributes for "commit"

  • expungeDeletes = "true" | "false" — default is false — merge segments with deletes away. <!> Solr1.4

Optional attributes for "optimize"

  • maxSegments = N — default is '1' — optimizes down to at most this number of segments <!> Solr1.3

Example of "commit" and "optimize" with optional attributes

<commit waitSearcher="false"/>
<commit waitSearcher="false" expungeDeletes="true"/>
<optimize waitSearcher="false"/>


在solrconfig.xml里有两个配置项,autoCommit和autoSoftCommit,他们是干什么的呢?他们是solr提交文档的两种方式。1. commit一般提交又或者叫硬提交(hard...
  • aiyueqingfeng
  • aiyueqingfeng
  • 2016年07月01日 18:07
  • 2529


在solr中,有硬提交和软提交两种方式索引数据: 硬提交: solrService.commit(true,true,true)其中硬提交是提交数据持久化到磁盘里面,并且能够查询到这条数据。 按照下面...
  • qq_20641565
  • qq_20641565
  • 2017年02月18日 13:43
  • 2036


最近又被soft commit 和 hard commit搞得有点迷糊,其实都怪自己没有早点看源代码。问题出自这段代码,这也是我一开始接触solr时,查到的代码sample(事实证明问题都出在这里,引...
  • zmywei_20160707
  • zmywei_20160707
  • 2017年10月17日 13:51
  • 57

solr 的commit, soft commit等

背景最近又被soft commit 和 hard commit搞得有点迷糊,其实都怪自己没有早点看源代码。问题出自这段代码,这也是我一开始接触solr时,查到的代码sample(事实证明问题都出在这里...
  • Oliverkehl
  • Oliverkehl
  • 2016年07月01日 14:50
  • 2106


转载: 从solr4.0起,solr多了一个软提交(softcommit...
  • limengliang4007
  • limengliang4007
  • 2017年09月26日 10:12
  • 309


  • thundersssss
  • thundersssss
  • 2010年03月16日 19:34
  • 5621


  • tianwei7518
  • tianwei7518
  • 2015年07月02日 22:07
  • 1474

框架 day71 Solr 全文检索服务 入门

Solr 全文搜索服务      1     Solr介绍 1.1     什么是solr Solr 是Apache下的一个顶级开源项目,采用Java开发,它是基于Lucene的全文搜索服务器。S...
  • opopopwqwqwq
  • opopopwqwqwq
  • 2016年07月30日 23:34
  • 2087

solr 自动提交autocommit(原创)

想让solr自动提交只需要修改solrconfig.xml文件的一些配置就能做到,方法很简单: 打开solrconfig.xml,增加以下配置(solrconfig.xml中以下配置已经被注释掉):...
  • dengsilinming
  • dengsilinming
  • 2012年07月27日 21:34
  • 6883


在solrconfig.xml里有两个配置项,autoCommit和autoSoftCommit,他们是干什么的呢?他们是solr提交文档的两种方式。 1. commit 一般提交又或者叫硬提交(...
  • asdfsadfasdfsa
  • asdfsadfasdfsa
  • 2017年05月13日 21:49
  • 323