简体   繁体   中英

ElasticSearch getting the last version of document

I store some documents in index "blog".

When I open URL http://localhost:9200/blog/post/90?pretty=true by browser I have the different value in "_version" field. ElasticSearch store 2 version of my document and return it randomly.

How to get the last document?

The _version property is used to implement optimistic locking. There cannot be two documents with a different version in the index. At least not in the same shard. Their might be a very short time frame in which the replicate shard can have an older version. Each update to the documents increases the version number. You can find more information about this in this blog post:

http://www.elasticsearch.org/blog/versioning/

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