# Query on version?

**URL:** https://discuss.elastic.co/t/query-on-version/6677
**Category:** Elasticsearch
**Created:** [February 11, 2012, 6:49am UTC](https://discuss.elastic.co/t/query-on-version/6677 "2012-02-11T06:49:04Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Mark\_Waddle](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_waddle/32/2608_2.png) [@Mark\_Waddle](https://discuss.elastic.co/u/Mark_Waddle)
#### Post date: [February 11, 2012, 6:49am UTC](https://discuss.elastic.co/t/query-on-version/6677/1 "2012-02-11T06:49:04Z")

</div>

Is it possible to query for documents that have a specific version number,  
or even better with a range?

This seems to hit all docs  
[http://localhost:9200/patent/grant/\_search?q=version:[2+TO+\*]&pretty=true&version=true](http://localhost:9200/patent/grant/_search?q=version:%5B2+TO+*%5D&pretty=true&version=true)

And these hit none  
[http://localhost:9200/patent/grant/\_search?q=\_version:[2+TO+\*]&pretty=true&version=true](http://localhost:9200/patent/grant/_search?q=_version:%5B2+TO+*%5D&pretty=true&version=true)  
[http://localhost:9200/patent/grant/\_search?q=version:2&pretty=true&version=true](http://localhost:9200/patent/grant/_search?q=version:2&pretty=true&version=true)  
[http://localhost:9200/patent/grant/\_search?q=\_version:2&pretty=true&version=true](http://localhost:9200/patent/grant/_search?q=_version:2&pretty=true&version=true)

I know I have at least a handful of docs with version of 2.

Thanks,

Mark

---

<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: [February 11, 2012, 10:56am UTC](https://discuss.elastic.co/t/query-on-version/6677/2 "2012-02-11T10:56:12Z")

</div>

It is not possible to query on the version number. I asked the same  
question a while back.

--  
Ivan

On Fri, Feb 10, 2012 at 10:49 PM, Mark Waddle [mark@markwaddle.com](mailto:mark@markwaddle.com) wrote:

> Is it possible to query for documents that have a specific version number,  
> or even better with a range?
> 
> This seems to hit all docs  
> [http://localhost:9200/patent/grant/\_search?q=version:[2+TO+\*]&pretty=true&version=true](http://localhost:9200/patent/grant/_search?q=version:%5B2+TO+*%5D&pretty=true&version=true)
> 
> And these hit none  
> [http://localhost:9200/patent/grant/\_search?q=\_version:[2+TO+\*]&pretty=true&version=true](http://localhost:9200/patent/grant/_search?q=_version:%5B2+TO+*%5D&pretty=true&version=true)  
> [http://localhost:9200/patent/grant/\_search?q=version:2&pretty=true&version=true](http://localhost:9200/patent/grant/_search?q=version:2&pretty=true&version=true)  
> [http://localhost:9200/patent/grant/\_search?q=\_version:2&pretty=true&version=true](http://localhost:9200/patent/grant/_search?q=_version:2&pretty=true&version=true)
> 
> I know I have at least a handful of docs with version of 2.
> 
> Thanks,
> 
> Mark

---

<div class="post-metadata">

### Author: ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)
#### Post date: [February 12, 2012, 3:06pm UTC](https://discuss.elastic.co/t/query-on-version/6677/3 "2012-02-12T15:06:57Z")

</div>

As Ivan pointed out, its not possible to do so. Why do you need it?

On Saturday, February 11, 2012 at 12:56 PM, Ivan Brusic wrote:

> It is not possible to query on the version number. I asked the same  
> question a while back.
> 
> --  
> Ivan
> 
> On Fri, Feb 10, 2012 at 10:49 PM, Mark Waddle \<[mark@markwaddle.com](mailto:mark@markwaddle.com) ([mailto:mark@markwaddle.com](mailto:mark@markwaddle.com))\> wrote:
> 
> > Is it possible to query for documents that have a specific version number,  
> > or even better with a range?
> > 
> > This seems to hit all docs  
> > [http://localhost:9200/patent/grant/\_search?q=version:[2+TO+\*]&pretty=true&version=true](http://localhost:9200/patent/grant/_search?q=version:%5B2+TO+*%5D&pretty=true&version=true)
> > 
> > And these hit none  
> > [http://localhost:9200/patent/grant/\_search?q=\_version:[2+TO+\*]&pretty=true&version=true](http://localhost:9200/patent/grant/_search?q=_version:%5B2+TO+*%5D&pretty=true&version=true)  
> > [http://localhost:9200/patent/grant/\_search?q=version:2&pretty=true&version=true](http://localhost:9200/patent/grant/_search?q=version:2&pretty=true&version=true)  
> > [http://localhost:9200/patent/grant/\_search?q=\_version:2&pretty=true&version=true](http://localhost:9200/patent/grant/_search?q=_version:2&pretty=true&version=true)
> > 
> > I know I have at least a handful of docs with version of 2.
> > 
> > Thanks,
> > 
> > Mark

---

<div class="post-metadata">

### Author: ![Mark\_Waddle](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_waddle/32/2608_2.png) [@Mark\_Waddle](https://discuss.elastic.co/u/Mark_Waddle)
#### Post date: [February 13, 2012, 8:27am UTC](https://discuss.elastic.co/t/query-on-version/6677/4 "2012-02-13T08:27:30Z")

</div>

Thanks for the responses. I am ingesting a number of documents that have been published over time, some of which are republished. I was hoping I could query on version to see those that have been indexed (published) more than once. Maybe I can use the new indexing feature that allows using script to increment another field?

Mark

---

<div class="post-metadata">

### Author: ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)
#### Post date: [February 13, 2012, 6:31pm UTC](https://discuss.elastic.co/t/query-on-version/6677/5 "2012-02-13T18:31:52Z")

</div>

Yes, I see. The update might help, but it only updates, it doesn't index a fresh copy.

On Monday, February 13, 2012 at 10:27 AM, Mark Waddle wrote:

> Thanks for the responses. I am ingesting a number of documents that have been published over time, some of which are republished. I was hoping I could query on version to see those that have been indexed (published) more than once. Maybe I can use the new indexing feature that allows using script to increment another field?
> 
> Mark

---

<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, 3:39am UTC](https://discuss.elastic.co/t/query-on-version/6677/6 "2017-07-06T03:39:35Z")

</div>


