_version field for several documents at once


(Lee Parker) #1

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


(Shay Banon) #2

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: 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


(Lee Parker) #3

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.comwrote:

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:
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


(Clinton Gormley) #4

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:

http://www.elasticsearch.org/blog/2011/03/24/new-search-types.html

clint


(system) #5