# Understanding filters cache for filters nested inside should clause of parent boolean query

**URL:** <https://discuss.elastic.co/t/understanding-filters-cache-for-filters-nested-inside-should-clause-of-parent-boolean-query/334511>\
**Category:** Elasticsearch\
**Created:** [May 27, 2023, 8:52pm UTC](https://discuss.elastic.co/t/understanding-filters-cache-for-filters-nested-inside-should-clause-of-parent-boolean-query/334511 "2023-05-27T20:52:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sarthak\_Madaan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sarthak_madaan/32/119198_2.png) [@Sarthak\_Madaan](https://discuss.elastic.co/u/Sarthak_Madaan)\
**Post date:** [May 27, 2023, 8:52pm UTC](https://discuss.elastic.co/t/understanding-filters-cache-for-filters-nested-inside-should-clause-of-parent-boolean-query/334511/1 "2023-05-27T20:52:39Z")

</div>

```auto
{
    "from": 0,
    "size": 2,
    "timeout": "10ms",
    "query": {
        "bool": {
            "should": [
                {
                    "bool": {
                        "filter": [
                            {
                                "term": {
                                    "mp": {
                                        "value": "F"
                                    }
                                }
                            },
                            {
                                "term": {
                                    "fc": {
                                        "value": 1
                                    }
                                }
                            },
                            {
                                "terms": {
                                    "ft": [
                                        "rating"
                                    ]
                                }
                            },
                            {
                                "terms": {
                                    "sp": [
                                         "j9e/abm/lbz/",
                                         "6bo/tia/ffn/0kj/"
                                    ]
                                    }
                                
                            },
                            {
                                "terms": {
                                    "ect": [
                                        "tr"
                                    ]
                                }
                            },
                            {
                                "term": {
                                    "ia": {
                                        "value": true
                                    }
                                }
                            }
                        ],
                        "must_not": [
                            {
                                "exists": {
                                    "field": "al"
                                }
                            },
                            {
                                "exists": {
                                    "field": "bu"
                                }
                            }
                        ],
                        "_name": "name"
                    }
                }
                ,{
                "bool": {
            "filter": [
                {
                    "terms": {
                        "fy": [
                            "flip"
                        ]
                    }
                },
                {
                    "terms": {
                        "fl": [
                            "fulfilled_by"
                        ]
                    }
                },
                {
                    "term": {
                        "ft": {
                            "value": 1
                        }
                    }
                },
                {
                    "term": {
                        "sp": {
                            "value": "clo/mz5/jbj/"
                        }
                    }
                },
                {
                    "term": {
                        "mp": {
                            "value": "F"
                        }
                    }
                },
                {
                    "terms": {
                        "ect": [
                            "fa"
                        ]
                    }
                },
                {
                    "term": {
                        "ia": {
                            "value": true
                        }
                    }
                }
            ],
            "must_not": [
                {
                    "exists": {
                        "field": "bu"
                    }
                },
                {
                    "exists": {
                        "field": "al"
                    }
                }
            ],
            "adjust_pure_negative": true,
            "_name": "name"
        }
                }
            ]
            }
        }
    
}

```

This is a boolean query with two nesting subqueries. The two nested subqueries contain filters. Will these filters leverage filter cache?  
I read that only the filter clause of a boolean query is cached. They are inside one boolean query with a should clause. Thats why need some explanation regarding it

---

<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:** [June 24, 2023, 8:52pm UTC](https://discuss.elastic.co/t/understanding-filters-cache-for-filters-nested-inside-should-clause-of-parent-boolean-query/334511/2 "2023-06-24T20:52:42Z")

</div>

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