# Is it possible to do disjoint queries or buckets?

**URL:** <https://discuss.elastic.co/t/is-it-possible-to-do-disjoint-queries-or-buckets/141033>\
**Category:** Elasticsearch\
**Created:** [July 22, 2018, 2:39pm UTC](https://discuss.elastic.co/t/is-it-possible-to-do-disjoint-queries-or-buckets/141033 "2018-07-22T14:39:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pulse14](https://avatars.discourse-cdn.com/v4/letter/p/ecb155/32.png) [@pulse14](https://discuss.elastic.co/u/pulse14)\
**Post date:** [July 22, 2018, 2:39pm UTC](https://discuss.elastic.co/t/is-it-possible-to-do-disjoint-queries-or-buckets/141033/1 "2018-07-22T14:39:09Z")

</div>

Hello,  
I have multiples simple bool queries Q1, Q2, .... Q100. (With 2 terms queries inside, and random scoring)  
Each query is associated to an integer N1, N2, ....N100.

I need to query N1 docs matching Q1, N2 docs matching Q2.... It is easy to do with filters aggregation and top hits.

But I also need disjoint bucket. I need docs to fall into the first matching bucket.  
If one doc fall into Q1 bucket, it can't fall into another bucket. If Q1 bucket is full (docs \> N1) then docs begging to fall into Q2 if they match.

Is it possible ?

Thank you

---

<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:** [August 19, 2018, 2:39pm UTC](https://discuss.elastic.co/t/is-it-possible-to-do-disjoint-queries-or-buckets/141033/2 "2018-08-19T14:39:15Z")

</div>

Closed on August 19, 2018, 2:39pm UTC

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