Updating a field results in error


(Muhammad) #1

When trying to update a field in a document like so:

POST index/doc/id/_update
{ "script": "ctx._source.test-field = 'Hello'"}

I get the following error:

{"error":{"root_cause":[{"type":"illegal_state_exception","reason":"There are no external requests known to support wildcards that don't support replacing their indices"}],"type":"illegal_state_exception","reason":"There are no external requests known to support wildcards that don't support replacing their indices"},"status":500}

I thought this was maybe due to dynamic field mapping being disabled so I manually added the new field to the index:

PUT index/_mapping/doc
{
"properties": {
"test-field": {
"type": "text"
}
}
}

which was fine but i still get the above error when i i try updating.

I am running version 6.3.1.

Any help would be appreciated.


(Abdon Pijpelink) #2

I can't reproduce your exact error, but one problem with your script is caused by the - in the field name test-field. You will want to use a slightly different syntax to access that field, ctx._source['test-field']:

POST index/doc/id/_update
{
  "script": "ctx._source['test-field'] = 'Hello'"
}

(system) closed #3

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