Multiple updates simultaneously on same document in solr

99封情书 提交于 2019-12-12 01:59:10

问题


I have a doubt regarding solr document update. For example, when two requests to update a document in solr comes at the same time, How does solr work?

  • Does it take one request randomly and locks write before next request comes in?

Thanks in Advance


回答1:


There are different Locking mechanisms as mentioned in Lucene locking factory docs. By default NativeFSLockFactory is used in which file lock is acquired for the document that is being indexed. The settings for using a different locking mechanism can be changed in solrconfig.xml

Here is a snippet from solconfig.xml

<!-- LockFactory 

     This option specifies which Lucene LockFactory implementation
     to use.

     single = SingleInstanceLockFactory - suggested for a
              read-only index or when there is no possibility of
              another process trying to modify the index.
     native = NativeFSLockFactory - uses OS native file locking.
              Do not use when multiple solr webapps in the same
              JVM are attempting to share a single index.
     simple = SimpleFSLockFactory  - uses a plain file for locking

     Defaults: 'native' is default for Solr3.6 and later, otherwise
               'simple' is the default

     More details on the nuances of each LockFactory...
     http://wiki.apache.org/lucene-java/AvailableLockFactories
-->
<lockType>${solr.lock.type:native}</lockType>



回答2:


Are you talking about physical locks or logical version control? For logical version control, Solr 4+ supports optimistic concurrency using version field.

You can read about it:

  1. Official documentation
  2. Detailed writeup


来源:https://stackoverflow.com/questions/23821568/multiple-updates-simultaneously-on-same-document-in-solr

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