# Update record in elasticsearch

**URL:** https://discuss.elastic.co/t/update-record-in-elasticsearch/170410
**Category:** Elasticsearch
**Created:** [February 28, 2019, 9:46pm UTC](https://discuss.elastic.co/t/update-record-in-elasticsearch/170410 "2019-02-28T21:46:32Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![rajatdey80](https://avatars.discourse-cdn.com/v4/letter/r/4af34b/32.png) [@rajatdey80](https://discuss.elastic.co/u/rajatdey80)
#### Post date: [February 28, 2019, 9:46pm UTC](https://discuss.elastic.co/t/update-record-in-elasticsearch/170410/1 "2019-02-28T21:46:32Z")

</div>

Hi All. ,

**I am not an expert in Elasticsearch, hence forgive me if this question is very silly . I am trying to update a record in. elastic search but unable to achieve the goal. .**  
**Elastic Version. : 6.6.** \*

Requirement :- To update the field value.  
Field name :- Source  
Current Value. :- %{[beat][hostname]}"

New Value. :- LMSS\_APP\_LOGIN

Update when matching condition

I tried following. :- but no luck.

_curl -X POST "[http://localhost:9200/graylog](http://localhost:9200/graylog)_ \*/ _update\_by\_query" -H 'Content-Type: application/json' -d'_  
_{_  
\_ "script": {\_  
\_ "inline":\_  
\_ "ctx. _source.data.oldValues.source=ctx. source.data.currentValues.source;  
\_ ctx. source.data.currentValues.source=params.newState.source;",  
\_ "params": {_  
\_ "newState": {"source": "LMSS\_APP\_LOGIN" }\_  
\_ }\_  
\_ },\_  
\_ "query": {\_  
\_ "term": {\_  
\_ "environment": "LMSS"\_  
\_ }\_  
\_ }\_  
_}_  
'  
}

Thrown following error.

**{"error":{"root\_cause":[{"type":"json\_parse\_exception","reason":"Illegal unquoted character ((CTRL-CHAR, code 10)): has to be escaped using backslash to be included in string value\n at [Source: org.elasticsearch.transport.netty4.ByteBufStreamInput@4ffc89c7; line: 5, column: 79]"}],"type":"json\_parse\_exception","reason":"Illegal unquoted character ((CTRL-CHAR, code 10)): has to be escaped using backslash to be included in string value\n at [Source: org.elasticsearch.transport.netty4.ByteBufStreamInput@4ffc89c7; line: 5, column: 79]"},"status":500}[root@rootlm01 scripts]#**  
**[root@rootlm01 scripts]#**

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [March 1, 2019, 1:38am UTC](https://discuss.elastic.co/t/update-record-in-elasticsearch/170410/2 "2019-03-01T01:38:31Z")

</div>

You already asked in [Need Help to Update Record in Elasticsearch Index](https://discuss.elastic.co/t/need-help-to-update-record-in-elasticsearch-index/169295). Let's keep the discussion there. No need to open a new question. The right thing to do is to ask again on the other thread which you just did as well.

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [March 1, 2019, 1:38am UTC](https://discuss.elastic.co/t/update-record-in-elasticsearch/170410/3 "2019-03-01T01:38:36Z")

</div>


