Skip to content

Version is ignored in Document Update API #42497

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ioanatia opened this issue May 24, 2019 · 2 comments
Closed

Version is ignored in Document Update API #42497

ioanatia opened this issue May 24, 2019 · 2 comments
Labels
>bug :Distributed Indexing/CRUD A catch all label for issues around indexing, updating and getting a doc by id. Not search.

Comments

@ioanatia
Copy link
Contributor

ioanatia commented May 24, 2019

Elasticsearch version (bin/elasticsearch --version):

Version: 7.1.0, Build: default/tar/606a173/2019-05-16T00:43:15.323135Z, JVM: 12.0.1

Description of the problem including expected versus actual behavior:

The docs specify that version is still a supported parameter.
However version seems to be ignored.
Other document APIs (e.g. delete) no longer support version.

Steps to reproduce:

PUT test
{
  "mappings": {
    "properties": {
      "name": { "type": "text" }
    }
  }
}

PUT test/_doc/1
{
  "name": "test1"
}

GET test/_doc/1

# does not support version, fails with validation error
DELETE test/_doc/1?version=10000

# this works in ES 7, but it shouldn't?
POST test/_update/1?version=10000
{ 
  "doc": {
    "name": "test2"
  }
}

response:
{
  "_index" : "test",
  "_type" : "_doc",
  "_id" : "1",
  "_version" : 2,
  "result" : "updated",
  "_shards" : {
    "total" : 2,
    "successful" : 1,
    "failed" : 0
  },
  "_seq_no" : 1,
  "_primary_term" : 1
}

As a side note, for noop updates it would be great if the response would contain _seq_no and _primary_term:

{
  "_index" : "test",
  "_type" : "_doc",
  "_id" : "1",
  "_version" : 2,
  "result" : "noop",
  "_shards" : {
    "total" : 0,
    "successful" : 0,
    "failed" : 0
  }
}
@iverase iverase added the :Distributed Indexing/CRUD A catch all label for issues around indexing, updating and getting a doc by id. Not search. label May 24, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-distributed

@ywelsch ywelsch added the >bug label May 24, 2019
dnhatn pushed a commit that referenced this issue Jul 16, 2019
The versioning of Update API doesn't rely on version number anymore (and
rather on sequence number). But in rest api level we ignored the
"version" and "version_type" parameter, so that the server cannot raise
the exception when whey were set.

This PR restores "version" and "version_type" parsing in Update Rest API
so that we can get the appropriate errors.

Relates to #42497
dnhatn pushed a commit that referenced this issue Jul 16, 2019
The versioning of Update API doesn't rely on version number anymore (and
rather on sequence number). But in rest api level we ignored the
"version" and "version_type" parameter, so that the server cannot raise
the exception when whey were set.

This PR restores "version" and "version_type" parsing in Update Rest API
so that we can get the appropriate errors.

Relates to #42497
@dnhatn
Copy link
Member

dnhatn commented Jul 19, 2019

Both points are addressed. @ioanatia Thank you for reporting this.

@dnhatn dnhatn closed this as completed Jul 19, 2019
dnhatn added a commit that referenced this issue Jul 19, 2019
With this change, we will return primary_term and seq_no of the current
document if an update is detected as a noop. We already return the
version; hence we should also return seq_no and primary_term.

Relates #42497
dnhatn added a commit that referenced this issue Jul 26, 2019
With this change, we will return primary_term and seq_no of the current
document if an update is detected as a noop. We already return the
version; hence we should also return seq_no and primary_term.

Relates #42497
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Distributed Indexing/CRUD A catch all label for issues around indexing, updating and getting a doc by id. Not search.
Projects
None yet
Development

No branches or pull requests

5 participants