Java API returns -1 as the first version where curl returns 1

Hi,

when following the guide regarding the version stuff all is fine:

Now I wanted to have this in my java project and tried the following:

But the search results in version -1 although I would expect 1 like it
is the case for the curl experiment.

This is especially bad as I want to fill the version from the
retrieved object and when feeding with a negative version ES throws an
exception **

What am I doing wrong?

Regards,
Peter.

**
Exception in thread "main"
org.elasticsearch.index.engine.VersionConflictEngineException: [index1]
[0] [something][1]: version conflict, current [-1], required [-1]
at
org.elasticsearch.index.engine.robin.RobinEngine.innerIndex(RobinEngine.java:
421)
at
org.elasticsearch.index.engine.robin.RobinEngine.index(RobinEngine.java:
374)
at
org.elasticsearch.index.shard.service.InternalIndexShard.index(InternalIndexShard.java:
292)
at
org.elasticsearch.action.index.TransportIndexAction.shardOperationOnPrimary(TransportIndexAction.java:
183)
at
org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction
$AsyncShardOperationAction.performOnPrimary(TransportShardReplicationOperationAction.java:
418)
at
org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction
$AsyncShardOperationAction.access
$100(TransportShardReplicationOperationAction.java:233)
at
org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction
$AsyncShardOperationAction
$1.run(TransportShardReplicationOperationAction.java:331)
at java.util.concurrent.ThreadPoolExecutor
$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor
$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)

You need to enable versioning to be returned, check this: Elasticsearch Platform — Find real-time answers at scale | Elastic. In Java its SearchRequestBuilder#setVersion.

On Tuesday, May 31, 2011 at 2:50 PM, Karussell wrote:

Hi,

when following the guide regarding the version stuff all is fine:

Elasticsearch Platform — Find real-time answers at scale | Elastic

Now I wanted to have this in my java project and tried the following:

Version Returning -1 on the first search · GitHub

But the search results in version -1 although I would expect 1 like it
is the case for the curl experiment.

This is especially bad as I want to fill the version from the
retrieved object and when feeding with a negative version ES throws an
exception **

What am I doing wrong?

Regards,
Peter.

**
Exception in thread "main"
org.elasticsearch.index.engine.VersionConflictEngineException: [index1]
[0] [something][1]: version conflict, current [-1], required [-1]
at
org.elasticsearch.index.engine.robin.RobinEngine.innerIndex(RobinEngine.java:
421)
at
org.elasticsearch.index.engine.robin.RobinEngine.index(RobinEngine.java:
374)
at
org.elasticsearch.index.shard.service.InternalIndexShard.index(InternalIndexShard.java:
292)
at
org.elasticsearch.action.index.TransportIndexAction.shardOperationOnPrimary(TransportIndexAction.java:
183)
at
org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction
$AsyncShardOperationAction.performOnPrimary(TransportShardReplicationOperationAction.java:
418)
at
org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction
$AsyncShardOperationAction.access
$100(TransportShardReplicationOperationAction.java:233)
at
org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction
$AsyncShardOperationAction
$1.run(TransportShardReplicationOperationAction.java:331)
at java.util.concurrent.ThreadPoolExecutor
$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor
$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)

Doh, thanks :slight_smile:

Too many versions :wink:

Thank you very much, I joined this forum to find answer for why java api returning -1 as version. Glad i did a search before posting a question. New to elastic search thoroughly enjoying its features. Java integration is first class.