# Query filtered by \_version range?

**URL:** <https://discuss.elastic.co/t/query-filtered-by--version-range/15367>\
**Category:** Elasticsearch\
**Created:** [January 23, 2014, 12:44am UTC](https://discuss.elastic.co/t/query-filtered-by--version-range/15367 "2014-01-23T00:44:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Paul\_Smith](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paul_smith/32/1323_2.png) [@Paul\_Smith](https://discuss.elastic.co/u/Paul_Smith)\
**Post date:** [January 23, 2014, 12:44am UTC](https://discuss.elastic.co/t/query-filtered-by--version-range/15367/1 "2014-01-23T00:44:24Z")

</div>

This has been asked before (I googled!), but I thought I'd seen some  
recent-or-maybe-not-that recent changes in ES about the special \_version  
field and being able to do 'something' extra with it other than it's use as  
the Optimistic Locking pattern.

Certainly in ES 0.19 one can't query it, but is that still the case in more  
recent ES versions at all? Just wanted to confirm if my memory of seeing  
something in this area is incorrect.

My use case is External Versioning using timestamps as the version, so  
being able to query items changed since a certain time would be useful. I  
could index a separate "queryableVersion" field with the same value, but  
maybe there's a better way.

cheers,

Paul

--  
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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAHfYWB5iagSPcp4xem-zZo4DJkHG3V07vkS%2BwsxBTPq2kfTCNQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAHfYWB5iagSPcp4xem-zZo4DJkHG3V07vkS%2BwsxBTPq2kfTCNQ%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [January 23, 2014, 12:53am UTC](https://discuss.elastic.co/t/query-filtered-by--version-range/15367/2 "2014-01-23T00:53:39Z")

</div>

The version field is not part of the underlying Lucene document and  
therefore it is not indexable/queryable.

However, you are correct in that my answer is old and perhaps there have  
been recent changes to provide that functionality. In the past, I looked  
into the issue and the problem is that the version is updated into the  
cluster state after the document has been committed. I am assuming the  
functionality does not exist since there might be consistency issues if the  
version value is updated before it is indexed. At least that is what I  
remember.

Cheers,

Ivan

On Wed, Jan 22, 2014 at 4:44 PM, Paul Smith [tallpsmith@gmail.com](mailto:tallpsmith@gmail.com) wrote:

> This has been asked before (I googled!), but I thought I'd seen some  
> recent-or-maybe-not-that recent changes in ES about the special \_version  
> field and being able to do 'something' extra with it other than it's use as  
> the Optimistic Locking pattern.
> 
> Certainly in ES 0.19 one can't query it, but is that still the case in  
> more recent ES versions at all? Just wanted to confirm if my memory of  
> seeing something in this area is incorrect.
> 
> My use case is External Versioning using timestamps as the version, so  
> being able to query items changed since a certain time would be useful. I  
> could index a separate "queryableVersion" field with the same value, but  
> maybe there's a better way.
> 
> cheers,
> 
> Paul
> 
> --  
> 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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/CAHfYWB5iagSPcp4xem-zZo4DJkHG3V07vkS%2BwsxBTPq2kfTCNQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAHfYWB5iagSPcp4xem-zZo4DJkHG3V07vkS%2BwsxBTPq2kfTCNQ%40mail.gmail.com)  
> .  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQCeWadJo%2B%2BaYu%3DAvBN5bUfXUk\_kcstaRp0JEYFj-Eu54g%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQCeWadJo%2B%2BaYu%3DAvBN5bUfXUk_kcstaRp0JEYFj-Eu54g%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 1:55am UTC](https://discuss.elastic.co/t/query-filtered-by--version-range/15367/3 "2017-07-06T01:55:15Z")

</div>


