Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to search documents by version?

Is it possible to search documents in Elastic Search index by version? I try this:

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

But it does not work.

I need such a query to get all documents, that have never been updated.

like image 500
Hovsep Avatar asked Jul 14 '14 06:07

Hovsep


Video Answer


2 Answers

Try using version

Returns a version for each search hit.

{
    "version": true,
    "query" : {
        "term" : { "user" : "kimchy" }
    }
}
like image 198
Siddardha Budige Avatar answered Sep 19 '22 20:09

Siddardha Budige


Unfortunately, you cannot query or filter by _version - the problem is that that 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

like image 34
John Petrone Avatar answered Sep 21 '22 20:09

John Petrone