# Updating a field results in error

**URL:** <https://discuss.elastic.co/t/updating-a-field-results-in-error/172838>\
**Category:** Elasticsearch\
**Created:** [March 18, 2019, 5:16pm UTC](https://discuss.elastic.co/t/updating-a-field-results-in-error/172838 "2019-03-18T17:16:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![farooq.muhammad41](https://avatars.discourse-cdn.com/v4/letter/f/d78d45/32.png) [@farooq.muhammad41](https://discuss.elastic.co/u/farooq.muhammad41)\
**Post date:** [March 18, 2019, 5:16pm UTC](https://discuss.elastic.co/t/updating-a-field-results-in-error/172838/1 "2019-03-18T17:16:11Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![abdon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abdon/32/9195_2.png) [@abdon](https://discuss.elastic.co/u/abdon)\
**Post date:** [March 20, 2019, 11:45am UTC](https://discuss.elastic.co/t/updating-a-field-results-in-error/172838/2 "2019-03-20T11:45:50Z")

</div>

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']`:

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

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [April 17, 2019, 11:45am UTC](https://discuss.elastic.co/t/updating-a-field-results-in-error/172838/3 "2019-04-17T11:45:53Z")

</div>

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