Hide a document from the searching in Elasticsearch

Viewed 229

We want to use Elasticsearch as primary data source, and we also want to keep track of changes of document, so we want to store all the versions of a document.

As a solution will be to hide previous document versions from the index, is this possible?

1 Answers

Elasticsearch has _version field, which is increased if you make a update to the same document, while query you can specify to get the highest version of a document to get the latest document.

More information on how to do is in elasticsearch version support blog

Edit:- Question asked in comment is that can we get a particular version document and answer is yes, also mentioned in official doc https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html and you can get it using query param but it has to be the current version otherwise you will get version_conflict_engine_exception, sample request looks like

http://{{hostname}}:{{port}}/{{index-name}}/_doc/2?version={your doc version}

Related