# Recommendations to Create Entity-Specific Models with Nested Hits/Documents

**URL:** https://discuss.elastic.co/t/recommendations-to-create-entity-specific-models-with-nested-hits-documents/261705
**Category:** Elasticsearch
**Tags:** transforms
**Created:** [January 20, 2021, 8:50pm UTC](https://discuss.elastic.co/t/recommendations-to-create-entity-specific-models-with-nested-hits-documents/261705 "2021-01-20T20:50:46Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![Hendrik\_Muhs](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hendrik_muhs/32/25802_2.png) [@Hendrik\_Muhs](https://discuss.elastic.co/u/Hendrik_Muhs)
#### Post date: [January 21, 2021, 3:06pm UTC](https://discuss.elastic.co/t/recommendations-to-create-entity-specific-models-with-nested-hits-documents/261705/2 "2021-01-21T15:06:32Z")

</div>

> [@jasonzissman](#):
>
> Elasticsearch transforms do not support aggregations that return hits/documents (e.g. top\_hits), so I do not see a way to leverage transforms to output a nested array of abbreviated events.

For accessing full documents you can to use a `scripted_metric` aggregation, the ootb aggregations work on single fields, not documents.

Top hits/metric won't help you, as you still need to collapse the entries into a document.

My advent calendar post from 2019 does collapsing the way you describe it, it is written in german, but maybe you can use in-built browser translation or a web service to translate it:

> [@Dec 5th, 2019 \[DE\] Weihnachtswünsche zusammenfassen mit Transforms](https://discuss.elastic.co/t/dec-5th-2019-de-weihnachtswunsche-zusammenfassen-mit-transforms/209946):
>
> Weihnachtswünsche zusammenfassen mit Transforms Zu Weihnachten gibt es die schöne Tradition des Wunschzettels, Kinder können hier Ihre Wünsche aufschreiben, aber auch Sorgen und andere Dinge dem Weihnachtsmann mitteilen. In Deutschland gibt es mehrere Weihnachtspostämter, die jährlich hunderttausende Briefe beantworten, noch viel mehr Wunschzettel bleiben wahrscheinlich innerhalb der Familie und landen bei den Eltern oder Großeltern. Stellen wir uns vor, dass auch beim Weihnachtsmann Fachkräfte…

---

_[View the full topic](https://discuss.elastic.co/t/recommendations-to-create-entity-specific-models-with-nested-hits-documents/261705)._
