How to search for documents by version?

Can I search for documents in the Elastic Search index by version? I try this:

curl -XGET eshost:9200/myindex/mytype/_search -d '{query:{match:{_version:"2"}}}' 

But that will not work.

I need such a request to get all the documents that have never been updated.

+7
elasticsearch
source share
3 answers

Unfortunately, you cannot query or filter _version - the problem is that this field is not indexed, so queries and filters cannot access it:

http://elasticsearch-users.115913.n3.nabble.com/Can-i-filter-query-by-version-td4044331.html

+4
source share

Try using the version

Returns the version for each search.

 { "version": true, "query" : { "term" : { "user" : "kimchy" } } } 
+8
source share

you can perform a search as usual, and set the version as true, and it will return you the number of all versions for each document:

 GET indextest/original/_search?pretty=true { "version": true } 
0
source share

All Articles