# Tuning my filter cache query

**URL:** <https://discuss.elastic.co/t/tuning-my-filter-cache-query/23955>\
**Category:** Elasticsearch\
**Created:** [June 19, 2015, 1:26am UTC](https://discuss.elastic.co/t/tuning-my-filter-cache-query/23955 "2015-06-19T01:26:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Srinivasan\_Ramaswamy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/srinivasan_ramaswamy/32/74106_2.png) [@Srinivasan\_Ramaswamy](https://discuss.elastic.co/u/Srinivasan_Ramaswamy)\
**Post date:** [June 19, 2015, 1:26am UTC](https://discuss.elastic.co/t/tuning-my-filter-cache-query/23955/1 "2015-06-19T01:26:05Z")

</div>

I want to make sure I have my filter cache query.

my schema looks like

```
product: {
	"properties": {
		"productId" : { "type": "long" }
		 //bunch of other properties
		 "offers": {
                "type": "nested",
                "properties": {
                	"offerId": {
                        "type": "long"
                    },
                    "categoryId": {
                        "type": "integer"
                    }
                 //bunch of other properties
                }
         }
	}
}

```

I am looking for some help in tuning the below query. We have a heap size of 16G and I have set 40% to filter cache, but still we are seeing 10 evictions per sec. I am unable to view the contents of filter cache (is there a way to do that?) Given that I want to make sure my query is optimal. If someone can help me validate my query it would be helpful.

{  
"query":{  
"function\_score":{  
"query":{  
"filtered":{  
"query":{  
"multi\_match":{  
"query":"bed",  
"fields":[  
"title",  
"editorialTitle"  
],  
"type":"most\_fields",  
"minimum\_should\_match":"3\<75%"  
}  
},  
"filter":{  
"bool":{  
"must":[  
{  
"nested":{  
"filter":{  
"terms":{  
"offers.categoryId":[0,1,2,3,4,5,6,7,8,17,23,32,37,38,42,45,49,50,51,52,65,74,75,77,78,86,89,90,96,100]  
}  
},  
"path":"products",  
"\_cache":true  
}  
},  
{  
"bool":{  
"must\_not":{  
"fquery":{  
"query":{  
"multi\_match":{  
"query":"some adult terms",  
"fields":[  
"title",  
"editorialTitle"  
]  
}  
},  
"\_cache":false  
}  
},  
"\_cache":true,  
"\_cache\_key":"notAdult"  
}  
}  
]  
}  
}  
}  
},  
"functions":[  
{  
"script\_score":{  
"script":"custom-scorer",  
"lang":"native",  
"params":{  
"categoryIds":[0,1,2,3,4,5,6,7,8,17,23,32,37,38,42,45,49,50,51,52,65,74,75,77,78,86,89,90,96,100],  
"query":"bed"  
}  
}  
}  
],  
"boost\_mode":"multiply"  
}  
},  
"explain":false,  
"sort":[  
{  
"\_score":{  
}  
},  
{  
"productId":{  
"order":"desc"  
}  
}  
]  
}

Note: we have category Ids that goes up to 3500 and we get different combination (but not too many unique ones) at times.

---

<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, 12:06am UTC](https://discuss.elastic.co/t/tuning-my-filter-cache-query/23955/2 "2017-07-06T00:06:34Z")

</div>


