# Filtered query - limiting result per id

**URL:** https://discuss.elastic.co/t/filtered-query-limiting-result-per-id/12420
**Category:** Elasticsearch
**Created:** [June 14, 2013, 4:00pm UTC](https://discuss.elastic.co/t/filtered-query-limiting-result-per-id/12420 "2013-06-14T16:00:05Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Anderson\_Bento](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anderson_bento/32/2288_2.png) [@Anderson\_Bento](https://discuss.elastic.co/u/Anderson_Bento)
#### Post date: [June 14, 2013, 4:00pm UTC](https://discuss.elastic.co/t/filtered-query-limiting-result-per-id/12420/1 "2013-06-14T16:00:05Z")

</div>

Hello to All 🙂

Today while I move to the office, I'm thinking about filters, and a  
question was created and I could not answer.

Can I limit the number of results per id?

For example, i have a filter by id with this values : ids: (1,2,3)

and this:

```
                "bool": {
                    "must": [
                        {
                            "term": {
                                "id": {
                                    "value": "1","2","3"
                                }
                            }
                        }
                    ]
                }
            }

```

and the size of query is 15... But I need 5 registrys per id

id 1 = [a,b,c,d,e]  
id 2 = [f,g,h,i,j]  
id 3 = [k,l,m,n,o]

It's possible today with elastic search? I can't use a different queries  
because I need the facet result, the best solution I see now is execute  
fou4 queries ( 1 to facet and 3 with the filters).

We have a better option?

Thanks!!!

--  
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:31am UTC](https://discuss.elastic.co/t/filtered-query-limiting-result-per-id/12420/2 "2017-07-06T02:31:12Z")

</div>


