# Update field based on regex results

**URL:** <https://discuss.elastic.co/t/update-field-based-on-regex-results/53056>\
**Category:** Elasticsearch\
**Created:** [June 16, 2016, 8:37pm UTC](https://discuss.elastic.co/t/update-field-based-on-regex-results/53056 "2016-06-16T20:37:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![TonyIT](https://avatars.discourse-cdn.com/v4/letter/t/a587f6/32.png) [@TonyIT](https://discuss.elastic.co/u/TonyIT)\
**Post date:** [June 16, 2016, 8:37pm UTC](https://discuss.elastic.co/t/update-field-based-on-regex-results/53056/1 "2016-06-16T20:37:48Z")

</div>

Hello!  
I'm new to ElasticSearch, and i need to create a field based on a query result.  
More specific, i need to make a query search on a field that contains only a specific substring, then i need to estract from this field a substring and write it into another field.  
There is a right way to do this?

i've already created the query that return only the documents that contains the specific query filter, but I don't know how to extract the specific substring from the document field with regex.

Thanks!

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [June 18, 2016, 1:32am UTC](https://discuss.elastic.co/t/update-field-based-on-regex-results/53056/2 "2016-06-18T01:32:06Z")

</div>

The only way I can think to do this would be to use the update-by-query API [https://www.elastic.co/guide/en/elasticsearch/reference/2.3/docs-update-by-query.html](https://www.elastic.co/guide/en/elasticsearch/reference/2.3/docs-update-by-query.html)

---

<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 5, 2017, 10:42pm UTC](https://discuss.elastic.co/t/update-field-based-on-regex-results/53056/3 "2017-07-05T22:42:36Z")

</div>


