# Update API script for adding a new field to a document

**URL:** <https://discuss.elastic.co/t/update-api-script-for-adding-a-new-field-to-a-document/201367>\
**Category:** Elasticsearch\
**Created:** [September 27, 2019, 9:16am UTC](https://discuss.elastic.co/t/update-api-script-for-adding-a-new-field-to-a-document/201367 "2019-09-27T09:16:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vladpov](https://avatars.discourse-cdn.com/v4/letter/v/8c91f0/32.png) [@Vladpov](https://discuss.elastic.co/u/Vladpov)\
**Post date:** [September 27, 2019, 9:16am UTC](https://discuss.elastic.co/t/update-api-script-for-adding-a-new-field-to-a-document/201367/1 "2019-09-27T09:16:48Z")

</div>

Hi everyone!

I need some help with script that could help me add a new field to the document if a condition is met.

The idea of script is something like : "Take log messages in a dataframe grouped by field 'ID' of message and compare with a field 'suffix' (two possible options: an/ln) and if the 'ID' has both of them, create a new field 'state' with value approved if not then value should be disapproved.

Maybe it could be solved without the script.

Any help would be appreciated!

---

<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:** [October 25, 2019, 9:16am UTC](https://discuss.elastic.co/t/update-api-script-for-adding-a-new-field-to-a-document/201367/2 "2019-10-25T09:16:50Z")

</div>

Closed on October 25, 2019, 9:16am UTC

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