# Find a document with query and modify a string in the message field

**URL:** <https://discuss.elastic.co/t/find-a-document-with-query-and-modify-a-string-in-the-message-field/236222>\
**Category:** Elasticsearch\
**Created:** [June 8, 2020, 7:47pm UTC](https://discuss.elastic.co/t/find-a-document-with-query-and-modify-a-string-in-the-message-field/236222 "2020-06-08T19:47:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cotjoey](https://avatars.discourse-cdn.com/v4/letter/c/76d3ee/32.png) [@cotjoey](https://discuss.elastic.co/u/cotjoey)\
**Post date:** [June 8, 2020, 7:47pm UTC](https://discuss.elastic.co/t/find-a-document-with-query-and-modify-a-string-in-the-message-field/236222/1 "2020-06-08T19:47:57Z")

</div>

Hello,

I have some filebeat events which were processed by Logstash and output in an Elasticsearch index. The documents in the index have a "message" field which contain a string that I need to modify.

Is there a command I can run (curl or Dev Tools) that can find the string I want and replace it, on the fly? I was thinking about a regexp query, but I cannot find the command to modify the field as well - it only does a search. This is an example of what I want to do:

i.e.

from:  
`message = "restart.sh -username MyUsername"`

to:  
`message = "restart.sh -username ?"`

So basically I want to find anything that matches "-username \<any\_string\>" and replace it with "-username ?".

Thank you,  
Joey

---

<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:** [July 6, 2020, 7:47pm UTC](https://discuss.elastic.co/t/find-a-document-with-query-and-modify-a-string-in-the-message-field/236222/2 "2020-07-06T19:47:57Z")

</div>

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