# TopHits vs 2 queries

**URL:** <https://discuss.elastic.co/t/tophits-vs-2-queries/65560>\
**Category:** Elasticsearch\
**Created:** [November 9, 2016, 9:36pm UTC](https://discuss.elastic.co/t/tophits-vs-2-queries/65560 "2016-11-09T21:36:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jonsgreen](https://avatars.discourse-cdn.com/v4/letter/j/e9bcb4/32.png) [@jonsgreen](https://discuss.elastic.co/u/jonsgreen)\
**Post date:** [November 9, 2016, 9:36pm UTC](https://discuss.elastic.co/t/tophits-vs-2-queries/65560/1 "2016-11-09T21:36:44Z")

</div>

I am doing a basic request in which I doing a terms aggregation grouping by an id associated with another document which is actually nested within the documents themselves. To be more specific these are GNIP tweet results and I am grouping retweets by the original tweet document. At first I was doing this as two queries first to get the ids and the to get the original tweet documents. However this proved to be one of our least performant requests so I experimented with adding a top\_hits aggregation instead since the information about the original tweet and author are container within the retweet document.

I was disappointed however to find that adding the top\_hits aggregation ended up taking more time even though I only have size 1 and set the collect\_mode to 'breadth\_first' on the terms aggregation.

I am curious whether that is to be expected that the 2 simpler queries would take less time than 1 query with the the top\_hits sub-aggregation.

If there is a better strategy for me to consider please let me know.

---

<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:** [December 7, 2016, 9:37pm UTC](https://discuss.elastic.co/t/tophits-vs-2-queries/65560/2 "2016-12-07T21:37:35Z")

</div>

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