# Getting top 1 result for each filter

**URL:** <https://discuss.elastic.co/t/getting-top-1-result-for-each-filter/13173>\
**Category:** Elasticsearch\
**Created:** [August 12, 2013, 12:01pm UTC](https://discuss.elastic.co/t/getting-top-1-result-for-each-filter/13173 "2013-08-12T12:01:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lucas\_Vanryb\_2](https://avatars.discourse-cdn.com/v4/letter/l/e95f7d/32.png) [@Lucas\_Vanryb\_2](https://discuss.elastic.co/u/Lucas_Vanryb_2)\
**Post date:** [August 12, 2013, 12:01pm UTC](https://discuss.elastic.co/t/getting-top-1-result-for-each-filter/13173/1 "2013-08-12T12:01:55Z")

</div>

Hi,

My problem is very simple.

I have products, each with a lot of attributes including the name and the  
category.

I want to get the #1 match for a string query in each category without  
doing one query by category.

Unfortunately filters facets only return count, so is there a way to do  
something like :

-\> Get results for my query (string)  
-\> For each category, apply a filter on these results and returns the #1  
result

I've been thinking about using facets filters but it would force me to put  
a term facet for each category, which seems to be the same thing as  
querying separately for each cat.

Thank you for your help,  
Lucas

--  
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:21am UTC](https://discuss.elastic.co/t/getting-top-1-result-for-each-filter/13173/2 "2017-07-06T02:21:35Z")

</div>

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


