Version is always -1


(Douglas Ferguson) #1

According to the docs version should auto increment when versionType is set
to INTERNAL (which is default and the value I have).

My observed behavior is that the version is always -1.

--


(Clinton Gormley) #2

On Sat, 2012-10-20 at 01:40 -0700, Douglas Ferguson wrote:

According to the docs version should auto increment when versionType
is set to INTERNAL (which is default and the value I have).

My observed behavior is that the version is always -1.

How about a gist demonstrating this.

clint

--


(Douglas Ferguson) #3

Here's a gist that demonstrates the issue:

https://gist.github.com/3924599

--


(Shay Banon) #4

Hey, can you try and actually ask for the version field in the search request (i.e. addField("version").addField("_source"))? If you don't ask for it its not returned by default.

Regarding the comments you have, yes, explain is expensive to ask for, and try and not use the DFS_… search type if you don't really need it.

On Oct 20, 2012, at 10:06 PM, Douglas Ferguson thedug@gmail.com wrote:

Here's a gist that demonstrates the issue:

https://gist.github.com/3924599

--

--


(Douglas Ferguson) #5

Thanks Shay!

Is there a good resource for understanding the differences between
termQuery, fieldQuery, match, etc?

Would you recommend that I stick with the Default QUERY_THEN_FETCH?

On Saturday, October 20, 2012 5:22:52 PM UTC-5, kimchy wrote:

Hey, can you try and actually ask for the version field in the search
request (i.e. addField("version").addField("_source"))? If you don't ask
for it its not returned by default.

Regarding the comments you have, yes, explain is expensive to ask for, and
try and not use the DFS_… search type if you don't really need it.

On Oct 20, 2012, at 10:06 PM, Douglas Ferguson <the...@gmail.com<javascript:>>
wrote:

Here's a gist that demonstrates the issue:

https://gist.github.com/3924599

--

--


(Shay Banon) #6

Yea, stick with QUERY_THEN_FETCH.

Regarding the queries, effectively, you actually care about mostly two queries:

  1. query_string: if you want to support the lucene query parser syntax
  2. match: for everything else. It does the right thing depending on the field index mapping, analysis, and type (like numerics).

On Oct 21, 2012, at 8:31 AM, Douglas Ferguson thedug@gmail.com wrote:

Thanks Shay!

Is there a good resource for understanding the differences between termQuery, fieldQuery, match, etc?

Would you recommend that I stick with the Default QUERY_THEN_FETCH?

On Saturday, October 20, 2012 5:22:52 PM UTC-5, kimchy wrote:
Hey, can you try and actually ask for the version field in the search request (i.e. addField("version").addField("_source"))? If you don't ask for it its not returned by default.

Regarding the comments you have, yes, explain is expensive to ask for, and try and not use the DFS_… search type if you don't really need it.

On Oct 20, 2012, at 10:06 PM, Douglas Ferguson the...@gmail.com wrote:

Here's a gist that demonstrates the issue:

https://gist.github.com/3924599

--

--

--


(Douglas Ferguson) #7

I actually got around to trying this and it still prints out -1 for version

SearchResponse results = client.prepareSearch(index)

.setQuery(QueryBuilders.fieldQuery("MyKey", "MyValue"))

     .addField("version").addField("_source")

     .execute()

     .actionGet();

System.err.println(results.getHits().getHits()[0].getVersion());

On Saturday, October 20, 2012 5:22:52 PM UTC-5, kimchy wrote:

Hey, can you try and actually ask for the version field in the search
request (i.e. addField("version").addField("_source"))? If you don't ask
for it its not returned by default.

Regarding the comments you have, yes, explain is expensive to ask for, and
try and not use the DFS_… search type if you don't really need it.

On Oct 20, 2012, at 10:06 PM, Douglas Ferguson <the...@gmail.com<javascript:>>
wrote:

Here's a gist that demonstrates the issue:

https://gist.github.com/3924599

--

--


(system) #8