# Limit multiple bool query in elasticsearch

**URL:** https://discuss.elastic.co/t/limit-multiple-bool-query-in-elasticsearch/193815
**Category:** Elasticsearch
**Created:** [August 5, 2019, 2:23pm UTC](https://discuss.elastic.co/t/limit-multiple-bool-query-in-elasticsearch/193815 "2019-08-05T14:23:52Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Youssfi\_Mohamed](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/youssfi_mohamed/32/51497_2.png) [@Youssfi\_Mohamed](https://discuss.elastic.co/u/Youssfi_Mohamed)
#### Post date: [August 5, 2019, 2:23pm UTC](https://discuss.elastic.co/t/limit-multiple-bool-query-in-elasticsearch/193815/1 "2019-08-05T14:23:52Z")

</div>

i have to search infos from elastic search so for that requirment i use a multiple bool query i want to limit each bool query size with different value from the other, that means each bool query have its own limit . so for that i use this code for the global query. can you help me please and thank you in advance

```
{
    "query": {
        "bool": {
            "filter": [
                    {
                    "range": {
                                "@timestamp":{"from" : "date1", "to" : "date2" }
                            }
                    },
                    {"bool" :{
                        "should": [
                                {"bool" : {
                                        "must": [
                                                    {
                                                      "match": {
                                                        "name": "bn1"
                                                      }
                                                    },
                                                    {
                                                      "match": {
                                                        "lastname": "l1"
                                                      }
                                                    },
                                                      {
                                                      "match": {
                                                        "old": "30"
                                                      }
                                                    }
                                                  ]
                                    }
                                },
                                {"bool" : {
                                        "must": [
                                                    {
                                                      "match": {
                                                        "name": "n2"
                                                      }
                                                    },
                                                    {
                                                      "match": {
                                                        "lastname": "l2"
                                                      }
                                                    },
                                                      {
                                                      "match": {
                                                        "old": "20"
                                                      }
                                                    }
                                                  ]
                                    }
                                }
                            ]
                        }
                    }
            ]
        }
    }
}
```

---

<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: [September 2, 2019, 2:37pm UTC](https://discuss.elastic.co/t/limit-multiple-bool-query-in-elasticsearch/193815/2 "2019-09-02T14:37:21Z")

</div>

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