简体   繁体   中英

Elasticsearch past version document

I want to maintain last 2 versions of documents in Elasticsearch.

I created, for example, first update for product123

 PUT /products/_doc/product123
   { "name" : "toothPaste",
     "price" : 10
    }

Then for second update product123:

  PUT /products/_doc/product123
    {
    "name" : "toothPaste",
    "price" : 12
    }

When I query using GET API - I am getting "price": 12 - Current Version

Is it possible that I will get "price": 10 (Last Version) of the same index

the only way to do this in Elasticsearch is to manage it yourself, as any updates applied to a document do not retain the previous version

you could do this using separate documents as MAZux mentioned above, or you could do it in different fields, eg price and previous_price

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