# \_version field for several documents at once

**URL:** https://discuss.elastic.co/t/-version-field-for-several-documents-at-once/4167
**Category:** Elasticsearch
**Created:** [March 29, 2011, 7:29pm UTC](https://discuss.elastic.co/t/-version-field-for-several-documents-at-once/4167 "2011-03-29T19:29:00Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Lee\_Parker](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lee_parker/32/3250_2.png) [@Lee\_Parker](https://discuss.elastic.co/u/Lee_Parker)
#### Post date: [March 29, 2011, 7:29pm UTC](https://discuss.elastic.co/t/-version-field-for-several-documents-at-once/4167/1 "2011-03-29T19:29:00Z")

</div>

Is there a reason that the document version data is not available as part of  
the search results? I am wanting this so that I can actually check on the  
current version of several documents at once. The only way I see to do this  
is to do a get by id on each document separately. Is there a good way to get  
several documents by id in a single query that will include the \_version  
field?

## Lee

"It doesn't matter whether you are liberal or conservative, but it's  
dangerous to always think with exclamation points instead of question  
marks."  
by Marty Beckerman

---

<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: [March 29, 2011, 7:31pm UTC](https://discuss.elastic.co/t/-version-field-for-several-documents-at-once/4167/2 "2011-03-29T19:31:11Z")

</div>

You can enable a search response to also return versions. It is not enabled by default since it does add a (small) overhead to search, and most times you don't need it. Here is how you enable it: [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/search/version.html).  
On Tuesday, March 29, 2011 at 9:29 PM, Lee Parker wrote:

> Is there a reason that the document version data is not available as part of the search results? I am wanting this so that I can actually check on the current version of several documents at once. The only way I see to do this is to do a get by id on each document separately. Is there a good way to get several documents by id in a single query that will include the \_version field?
> 
> ## Lee
> 
> "It doesn't matter whether you are liberal or conservative, but it's dangerous to always think with exclamation points instead of question marks."  
> by Marty Beckerman

---

<div class="post-metadata">

### Author: ![Lee\_Parker](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lee_parker/32/3250_2.png) [@Lee\_Parker](https://discuss.elastic.co/u/Lee_Parker)
#### Post date: [March 29, 2011, 8:50pm UTC](https://discuss.elastic.co/t/-version-field-for-several-documents-at-once/4167/3 "2011-03-29T20:50:14Z")

</div>

Is there a better way to get several documents by id? I was planning to do a  
query like  
{  
"query": {  
"terms" : {  
"\_id" : [id1,id2,id3,...id50]  
}  
}  
}

## Lee

"It doesn't matter whether you are liberal or conservative, but it's  
dangerous to always think with exclamation points instead of question  
marks."  
by Marty Beckerman  
On Tue, Mar 29, 2011 at 2:31 PM, Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)wrote:

> You can enable a search response to also return versions. It is not  
> enabled by default since it does add a (small) overhead to search, and most  
> times you don't need it. Here is how you enable it:  
> [Elastic — The Search AI Company | Elastic](http://www.elasticsearch.org/guide/reference/api/search/version.html).
> 
> On Tuesday, March 29, 2011 at 9:29 PM, Lee Parker wrote:
> 
> Is there a reason that the document version data is not available as part  
> of the search results? I am wanting this so that I can actually check on the  
> current version of several documents at once. The only way I see to do this  
> is to do a get by id on each document separately. Is there a good way to get  
> several documents by id in a single query that will include the \_version  
> field?
> 
> ## Lee
> 
> "It doesn't matter whether you are liberal or conservative, but it's  
> dangerous to always think with exclamation points instead of question  
> marks."  
> by Marty Beckerman

---

<div class="post-metadata">

### Author: ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)
#### Post date: [March 30, 2011, 8:03am UTC](https://discuss.elastic.co/t/-version-field-for-several-documents-at-once/4167/4 "2011-03-30T08:03:30Z")

</div>

On Tue, 2011-03-29 at 15:50 -0500, Lee Parker wrote:

> Is there a better way to get several documents by id? I was planning  
> to do a query like  
> {  
> "query": {  
> "terms" : {  
> "\_id" : [id1,id2,id3,...id50]  
> }  
> }  
> }

The above would be the best way to get multiple docs by ID. In master,  
you could also use the 'scan' search\_type with scrolling, to chunk your  
get and make it more efficient on the server side:

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

clint

---

<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, 4:09am UTC](https://discuss.elastic.co/t/-version-field-for-several-documents-at-once/4167/5 "2017-07-06T04:09:09Z")

</div>


