-
Notifications
You must be signed in to change notification settings - Fork 25.8k
_update API should check the syntax in case of scripted updates #28740
Copy link
Copy link
Closed
Labels
:Data Management/Indices APIsDO NOT USE. Use ":Distributed/Indices APIs" or ":StorageEngine/Templates" instead.DO NOT USE. Use ":Distributed/Indices APIs" or ":StorageEngine/Templates" instead.>bughelp wantedadoptmeadoptme
Description
Elasticsearch version (bin/elasticsearch --version): 6.1.2
Plugins installed: []
Description of the problem including expected versus actual behavior:
The _update API doesn't seem to reject a command that is wrong. Actually, this example comes from The Definitive Guide (which I know it's WIP), but still the ES API should reply back with an error for such a command:
POST /website/blog/1/_update
{
"script": "ctx.op = ctx._source.views == params.count ? 'delete' : 'none'",
"params": {
"count": 1
}
}
This returns:
{
"_index": "website",
"_type": "blog",
"_id": "1",
"_version": 2,
"result": "noop",
"_shards": {
"total": 0,
"successful": 0,
"failed": 0
}
}
Debugging this with Debug.explain(params) shows that there is no params registered. Which, in fact, is fine since the syntax is incorrect: there shouldn't be any params definitions at the root level, but inside script itself. The correct syntax should be:
POST /website/blog/1/_update
{
"script": {
"source": "ctx.op = ctx._source.views == params.count ? 'delete' : 'none'",
"params": {
"count": 1
}
}
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
:Data Management/Indices APIsDO NOT USE. Use ":Distributed/Indices APIs" or ":StorageEngine/Templates" instead.DO NOT USE. Use ":Distributed/Indices APIs" or ":StorageEngine/Templates" instead.>bughelp wantedadoptmeadoptme
Type
Fields
Give feedbackNo fields configured for issues without a type.