# Merge document by condition

**URL:** <https://discuss.elastic.co/t/merge-document-by-condition/268046>\
**Category:** Elasticsearch\
**Created:** [March 23, 2021, 6:20am UTC](https://discuss.elastic.co/t/merge-document-by-condition/268046 "2021-03-23T06:20:30Z")\
**Posts on this page:** 1\
**Showing post:** 4

<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:** [March 23, 2021, 7:19am UTC](https://discuss.elastic.co/t/merge-document-by-condition/268046/4 "2021-03-23T07:19:51Z")

</div>

It's hard to say without a concrete example of the documents you have.

Could you provide a full recreation script as described in [About the Elasticsearch category](https://discuss.elastic.co/t/about-the-elasticsearch-category/21). It will help to better understand what you are doing. Please, try to keep the example as simple as possible.

A full reproduction script is something anyone can copy and paste in Kibana dev console, click on the run button to reproduce your use case. It will help readers to understand, reproduce and if needed fix your problem. It will also most likely help to get a faster answer.

But anyway, may be [top hits](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-top-hits-aggregation.html) is what you want to have?

---

_[View the full topic](https://discuss.elastic.co/t/merge-document-by-condition/268046)._
