Add Scripted fields through curl

Hi,

I want to add scripted field through curl.

I know I have to update .kibana index specifically the doc of that index pattern.

Below is the code that I am executing to add scripted field test in the index pattern pattern_name

POST .kibana/doc/index-pattern:pattern_name/_update
{
"script": "ctx._source.new_field ={'name':'test',
'type':'number',
'count':0,
'scripted':true,
'script':4150,
'lang':'painless',
'searchable':true,
'aggregatable':true,
'readFromDocValues':false}"
}

I get the error saying
"type": "illegal_argument_exception",
"reason": "failed to execute script",
"caused_by": {
"type": "script_exception",
"reason": "compile error",
"script_stack": [
"ctx._source.new_field = {'name':'test','type':'nu ...",
" ^---- HERE"
],
"script": "ctx._source.new_field = {'name':'test','type':'number','count':0,'scripted':true,'script':'4150','lang':'painless','searchable':true,'aggregatable':true,'readFromDocValues':false}",
"lang": "painless",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "invalid sequence of tokens near ['{'].",
"caused_by": {
"type": "no_viable_alt_exception",
"reason": null
}
}
}
},
"status": 400
}

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