9

Is there any way to retrieve older version of same document in elasticsearch? Suppose I've indexed 1 document in ES:

put class/student/1
{
    "marks":95
}

Later point of time I want to update it to:

put class/student/1
    {
        "marks":96
    }

As soon as I index the updated marks, I see '_version' getting updated as 2. Is there any way to query ES and get _version=1 document?

Vineeth Mohan
  • 18,633
  • 8
  • 63
  • 77
Satish
  • 2,478
  • 2
  • 17
  • 22

1 Answers1

13

This is not possible. Even though there is a version number associated with each create/index/update/delete operation, this version number can't be used to retrieve the older version of the document. Rather it can be used to prevent dirty reads while read/manipulate/index operations

Mate Mrše
  • 7,997
  • 10
  • 40
  • 77
Vineeth Mohan
  • 18,633
  • 8
  • 63
  • 77
  • Vineeth, do u mean to say ES doesn't come with retrieval of older versio documents? In case I want to go back to older version of document and check the necessary fields what I need to do then? – Satish Dec 26 '14 at 03:43
  • You will need to maintain versions yourself. As in create a new document for each document change or something in that line. Another option would be to maintain documents in couchDB or some other DB which has versioning support and then use Elasticsearch for search. Hence you need to replicate data to both databases. – Vineeth Mohan Dec 26 '14 at 03:57