# Retrieve each filter response in one result

**URL:** https://discuss.elastic.co/t/retrieve-each-filter-response-in-one-result/289467
**Category:** Elasticsearch
**Created:** [November 17, 2021, 3:20pm UTC](https://discuss.elastic.co/t/retrieve-each-filter-response-in-one-result/289467 "2021-11-17T15:20:04Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![uedemir](https://avatars.discourse-cdn.com/v4/letter/u/a6a055/32.png) [@uedemir](https://discuss.elastic.co/u/uedemir)
#### Post date: [November 17, 2021, 3:20pm UTC](https://discuss.elastic.co/t/retrieve-each-filter-response-in-one-result/289467/1 "2021-11-17T15:20:04Z")

</div>

Hi,

Is it possible to combine three or more filter query with each wished **size** and get ids of document separately in result?

For example; `size` parameter in query is 100 and I need to get 10 documents from first of my filter which `"my_field": "foo"` and 20 documents from second of my filter which `"another_field": "bar"` etc .

Desired result;

```auto
{
...,
"hits" : {
    "total" : {
      "value" : 100,
      "relation" : "eq"
    },
    "hits" : [
      {
        ....,
        "result_one" : {
          "ids" : [1,2,3,4,....] # total count 10 or less
        },
        "result_two" : {
          "ids" : [10,20,30,....] # total count 20 or less
        },
        "result_three" : {
          "ids" : [9, 8, 7,....]
        }
      }
    ]
  }
}

```

I can achieve this with making 3 `_search` request to my index but is there any way to make this only one request?

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [November 17, 2021, 3:57pm UTC](https://discuss.elastic.co/t/retrieve-each-filter-response-in-one-result/289467/2 "2021-11-17T15:57:00Z")

</div>

You can use an \_msearch request with three queries.

---

<div class="post-metadata">

### Author: ![uedemir](https://avatars.discourse-cdn.com/v4/letter/u/a6a055/32.png) [@uedemir](https://discuss.elastic.co/u/uedemir)
#### Post date: [November 18, 2021, 8:36am UTC](https://discuss.elastic.co/t/retrieve-each-filter-response-in-one-result/289467/3 "2021-11-18T08:36:37Z")

</div>

Thank you for advice.

---

<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 16, 2021, 8:36am UTC](https://discuss.elastic.co/t/retrieve-each-filter-response-in-one-result/289467/4 "2021-12-16T08:36:55Z")

</div>

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