# Event.remove method not working inside aggregate section in code block

**URL:** <https://discuss.elastic.co/t/event-remove-method-not-working-inside-aggregate-section-in-code-block/336201>\
**Category:** Logstash\
**Created:** [June 16, 2023, 9:20am UTC](https://discuss.elastic.co/t/event-remove-method-not-working-inside-aggregate-section-in-code-block/336201 "2023-06-16T09:20:21Z")\
**Posts on this page:** 1\
**Showing post:** 18

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [June 18, 2023, 2:51am UTC](https://discuss.elastic.co/t/event-remove-method-not-working-inside-aggregate-section-in-code-block/336201/18 "2023-06-18T02:51:55Z")

</div>

> [@J\_S](#):
>
> `doc_as_upsert => true`

I think you have misunderstood what that does. See [this](https://discuss.elastic.co/t/prevent-upsert-to-merge-internal-objects-in-logstash-configuration/148061) thread.

I suggest you ask a new question, saying: I am repeatedly fetching rows from a database. I insert them into elasticsearch using the unique key as the document\_id. For any fields not on the current document I want to add any missing columns to the exiting documents. For fields that _do_ exist on the current document (including hashes) I want to overwrite them. How can I do this?

---

_[View the full topic](https://discuss.elastic.co/t/event-remove-method-not-working-inside-aggregate-section-in-code-block/336201)._
