# Fastest query for returning 1 result for each term

**URL:** <https://discuss.elastic.co/t/fastest-query-for-returning-1-result-for-each-term/11908>\
**Category:** Elasticsearch\
**Created:** [May 9, 2013, 10:00pm UTC](https://discuss.elastic.co/t/fastest-query-for-returning-1-result-for-each-term/11908 "2013-05-09T22:00:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nariman\_Haghighi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nariman_haghighi/32/1065_2.png) [@Nariman\_Haghighi](https://discuss.elastic.co/u/Nariman_Haghighi)\
**Post date:** [May 9, 2013, 10:00pm UTC](https://discuss.elastic.co/t/fastest-query-for-returning-1-result-for-each-term/11908/1 "2013-05-09T22:00:36Z")

</div>

I have an index of tweets where each document has a URL, text and 1 or more  
tags.

A terms facet on tags gets produces the top 20 most popular tags - this is  
great.

In a second query, for each of these 20 distinct tags, I'd like to pull out  
a sample document (doesn't matter which one).

Is this possible within a single query or does it need multi-search?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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:** [May 9, 2013, 10:08pm UTC](https://discuss.elastic.co/t/fastest-query-for-returning-1-result-for-each-term/11908/2 "2013-05-09T22:08:04Z")

</div>

IMHO, multisearch is the way to go.

HTH

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 10 mai 2013 à 00:00, Nariman Haghighi [auspicious@gmail.com](mailto:auspicious@gmail.com) a écrit :

I have an index of tweets where each document has a URL, text and 1 or more tags.

A terms facet on tags gets produces the top 20 most popular tags - this is great.

In a second query, for each of these 20 distinct tags, I'd like to pull out a sample document (doesn't matter which one).

## Is this possible within a single query or does it need multi-search?

You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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:** [July 6, 2017, 2:37am UTC](https://discuss.elastic.co/t/fastest-query-for-returning-1-result-for-each-term/11908/3 "2017-07-06T02:37:15Z")

</div>

Closed on July 6, 2017, 2:37am UTC


