# Update a field

**URL:** <https://discuss.elastic.co/t/update-a-field/185336>\
**Category:** Elasticsearch\
**Created:** [June 12, 2019, 6:31am UTC](https://discuss.elastic.co/t/update-a-field/185336 "2019-06-12T06:31:09Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![saramali](https://avatars.discourse-cdn.com/v4/letter/s/da6949/32.png) [@saramali](https://discuss.elastic.co/u/saramali)\
**Post date:** [June 12, 2019, 6:31am UTC](https://discuss.elastic.co/t/update-a-field/185336/1 "2019-06-12T06:31:09Z")

</div>

Hi,

I have an index which has documents of all the commits of my repo.

There is a field in the document which has different format therefore while aggregating on that field yields different result.

The field name is Author.

Different format example

format 1 : saram ali\<[saram.ali@email.com](mailto:saram.ali@email.com)\>  
format 2: Saram Ali \<[saram.ali@email.com](mailto:saram.ali@email.com)\>

Since they are both the same author with different format in the document field.  
Is there any way I can only extract the email from this field and update this field. I have 1.5 Million documents having this field.

---

<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:** [June 12, 2019, 6:42am UTC](https://discuss.elastic.co/t/update-a-field/185336/2 "2019-06-12T06:42:25Z")

</div>

Did you mean using Update By Query API?

---

<div class="post-metadata">

**Author:** ![saramali](https://avatars.discourse-cdn.com/v4/letter/s/da6949/32.png) [@saramali](https://discuss.elastic.co/u/saramali)\
**Post date:** [June 12, 2019, 6:43am UTC](https://discuss.elastic.co/t/update-a-field/185336/3 "2019-06-12T06:43:43Z")

</div>

That could be one of the propositions, I'm looking for an efficient solution also if it's possible or not as well.

Since the records are 1.5 million

---

<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:** [June 12, 2019, 7:02am UTC](https://discuss.elastic.co/t/update-a-field/185336/4 "2019-06-12T07:02:27Z")

</div>

You have to reindex those documents anyway. Depending and the whole size of the dataset a full reindex in a new index might be better.

---

<div class="post-metadata">

**Author:** ![saramali](https://avatars.discourse-cdn.com/v4/letter/s/da6949/32.png) [@saramali](https://discuss.elastic.co/u/saramali)\
**Post date:** [June 12, 2019, 7:04am UTC](https://discuss.elastic.co/t/update-a-field/185336/5 "2019-06-12T07:04:19Z")

</div>

For updating what do you suggest, how should I update the field while reindexing.

---

<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:** [June 12, 2019, 8:35am UTC](https://discuss.elastic.co/t/update-a-field/185336/6 "2019-06-12T08:35:11Z")

</div>

- Reindex from remote: [Reindex API | Elasticsearch Guide [8.11] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html#reindex-from-remote)
- Update By Query: [Update By Query API | Elasticsearch Guide [8.11] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update-by-query.html)

> how should I update the field while reindexing.

You probably want to apply some text transformation. You can use a Painless Script while updating to apply whatever rule you need.

---

<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 10, 2019, 8:35am UTC](https://discuss.elastic.co/t/update-a-field/185336/7 "2019-07-10T08:35:13Z")

</div>

Closed on July 10, 2019, 8:35am UTC

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