Filter by _version and show _version in elasticsearch query

How can I filter by the _version field in elasticsearch? I tried to run
the following query (using YAML instead of JSON) to get documents with
_version greater than or equal to 4, but nothing is getting returned even
though the document definitely has documents with that version number.

query:
    filtered:
        filter:
            range:
                _version:
                    gte: 4

I know _version is working because in general I can do aggregations on it
like

aggs:
    versions:
        terms:
            field: _version

Also how can I get _version to appear in the list of fields? I try the
following but only the name field is shown, not version.

fields:
    - name
    - _version

I haven't done anything in my mapping regarding _version, do I need to
customize it's mapping in some way before I can filter or display it?

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/16d20efb-3967-43f8-a860-b694d70ef4ee%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Hi,

While using the _version might seem to work in certain cases, I would
recommend to never use it for anything else than optimistic locking of
updates. In particular, versions do not carry any meaning: they might look
like the number of times a document has been modified but it is not always
the case (for instance if you create a new document which has the same ID
as a document that you just deleted, the version number of the new document
will not be 1), and more importantly it is an implementation detail, this
behaviour might change in the future.

On Sat, Feb 7, 2015 at 12:07 PM, es5z veerukrishnan@hotmail.com wrote:

How can I filter by the _version field in elasticsearch? I tried to run
the following query (using YAML instead of JSON) to get documents with
_version greater than or equal to 4, but nothing is getting returned even
though the document definitely has documents with that version number.

query:
    filtered:
        filter:
            range:
                _version:
                    gte: 4

I know _version is working because in general I can do aggregations on
it like

aggs:
    versions:
        terms:
            field: _version

Also how can I get _version to appear in the list of fields? I try the
following but only the name field is shown, not version.

fields:
    - name
    - _version

I haven't done anything in my mapping regarding _version, do I need to
customize it's mapping in some way before I can filter or display it?

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/16d20efb-3967-43f8-a860-b694d70ef4ee%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/16d20efb-3967-43f8-a860-b694d70ef4ee%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--
Adrien Grand

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j6RCOK350GjQLOEu%2B1ZgMZMTvsYG61%3DxKfX6Sj%3D6bs%3DDA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Wasn't aware it's an implementation detail, thanks. That being said, does
it mean there's no way to list _version in the fields that have been
output, or to filter by them? I'd assume that since aggregations with them
work that there'd be a way to filter and view it.

On Sunday, February 8, 2015 at 7:48:26 PM UTC+1, Adrien Grand wrote:

Hi,

While using the _version might seem to work in certain cases, I would
recommend to never use it for anything else than optimistic locking of
updates. In particular, versions do not carry any meaning: they might look
like the number of times a document has been modified but it is not always
the case (for instance if you create a new document which has the same ID
as a document that you just deleted, the version number of the new document
will not be 1), and more importantly it is an implementation detail, this
behaviour might change in the future.

On Sat, Feb 7, 2015 at 12:07 PM, es5z <veeruk...@hotmail.com <javascript:>

wrote:

How can I filter by the _version field in elasticsearch? I tried to run
the following query (using YAML instead of JSON) to get documents with
_version greater than or equal to 4, but nothing is getting returned even
though the document definitely has documents with that version number.

query:
    filtered:
        filter:
            range:
                _version:
                    gte: 4

I know _version is working because in general I can do aggregations on
it like

aggs:
    versions:
        terms:
            field: _version

Also how can I get _version to appear in the list of fields? I try the
following but only the name field is shown, not version.

fields:
    - name
    - _version

I haven't done anything in my mapping regarding _version, do I need to
customize it's mapping in some way before I can filter or display it?

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearc...@googlegroups.com <javascript:>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/16d20efb-3967-43f8-a860-b694d70ef4ee%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/16d20efb-3967-43f8-a860-b694d70ef4ee%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--
Adrien Grand

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/c7df181d-179c-4480-bfeb-322a9497c611%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.