Elasticsearch 5.6.0, Unknown setting score while updating with ctx script

On 5.6.0, when updating a field with ctx._source.field via inline script using high-level-rest-client, I'm getting unknown source setting error. It should work fine as I'm using "ctx._source" as per documentation, not "_source". So, please help on why I'm facing this issue.

Error : org.elasticsearch.ElasticsearchStatusException: Elasticsearch exception [type=illegal_argument_exception, reason=[script] unknown field [source], parser not found]

Code snippet :
UpdateRequest request = new UpdateRequest(index, type,id);
request.script(new Script(ScriptType.INLINE, "painless", scriptQuery, paramsField));
bulkRequest.add(request);
getHighLevelClient().bulk(bulkRequest);

But via API, it is working fine and field updated successfully when using same script

curl -XPOST 'http://localhost:9200/index/type/id/_update' -d '{ "script" : { "inline": "if (ctx._source.containsKey("status")) else {ctx._source.status=params.status}", "lang": "painless", "params" : { "status":"unpublished"}}}'

Seems this issue is not with ctx._source. but with script builder itself of high-level rest client. I tried search with script where _source is not used, only _score and a field is used. Getting the same error. Please help.

Code :
QueryBuilders.functionScoreQuery(
ScoreFunctionBuilders.scriptFunction(new Script("_score * doc['custom_weight'].value")))

forms like,

{ "function_score" : { "script_score" : { "lang" : "painless", "source" : "_score * doc['custom_weight'].value" } } }

Is the source error related to script_score.source? Any help is appreciated. Thanks.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.