简体   繁体   中英

Concurrent edits to a lucene document

I noticed there this this method: https://lucene.apache.org/core/6_1_0/core/org/apache/lucene/index/IndexWriter.html#updateDocument-org.apache.lucene.index.Term-java.lang.Iterable-

So I would first pull out the document, make the change and then use the above method to update via uid. This implies I require external synchronisation if I have concurrent updates.

Or is there another way to do this that I am not aware of?

As written on mentioned above link

The delete and then add are atomic as seen by a reader on the same index.

That means no other thread can observe the modification half-complete, will either see the value before the update, or after the update.

So it is better to do external synchronization for concurrent updates.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM