elastic/elasticsearch

Update API: Setting ctx.op to random string results in noop

Open

#43,514 opened on Jun 22, 2019

View on GitHub
 (8 comments) (0 reactions) (0 assignees)Java (76,700 stars) (25,882 forks)batch import
:Distributed/CRUDTeam:Distributedhelp wanted

Description

Elasticsearch version (bin/elasticsearch --version): 7.1.1

Description of the problem including expected versus actual behavior:

When using a script in the Update API, setting ctx.op to any string will result in a noop. IMO this should throw an exception, if it's anything else than the suggested ones.

This leniency is actually documented with a TODO, but I do not know the history behind that (that todo is from early 2017). Also a warn message is logged.

Steps to reproduce:

DELETE test

PUT test/_doc/1
{
  "key" : "value"
}

POST test/_update/1
{
  "script": {
    "source": "ctx._source.foo = 'bar'; ctx.op ='anything'",
    "lang": "painless"
  }
}

# document unchanged
GET test/_doc/1

Contributor guide