# Using constant multi\_match query as filter

**URL:** <https://discuss.elastic.co/t/using-constant-multi-match-query-as-filter/67240>\
**Category:** Elasticsearch\
**Created:** [November 26, 2016, 1:18pm UTC](https://discuss.elastic.co/t/using-constant-multi-match-query-as-filter/67240 "2016-11-26T13:18:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![xabbu42](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/xabbu42/32/44817_2.png) [@xabbu42](https://discuss.elastic.co/u/xabbu42)\
**Post date:** [November 26, 2016, 1:18pm UTC](https://discuss.elastic.co/t/using-constant-multi-match-query-as-filter/67240/1 "2016-11-26T13:18:15Z")

</div>

Hi

I implemented a filter for adult pages in a web search using a multi\_match query like the following:  
{  
"multi\_match": {  
"fields": [  
"content",  
"meta.description",  
"meta.keywords"  
],  
"type": "cross\_fields",  
"query": "long nsfw word list",  
"minimum\_should\_match": 6,  
"operator": "or",  
"boost": 0  
}  
}

I was hoping that this would be cacheable as the adult query never changes.  
But currently it seems to have some overhead on queries (an intern query with 0 results is 10 ms without adult filter and 40 ms with adult filter, a normal user search with ca 500000 results is 100ms without and 250 with).

Can I somehow force elasticsearch to cache the results of this query?  
Any other ideas on how to construct an adult filter with less overhead?

I can of course just calculate an adult flag at index time, which is the current plan but a lot less flexible than a cached query would be.

We currently use elasticsearch 2.4.1

Greetings  
Nathan Gass

---

<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 24, 2016, 1:18pm UTC](https://discuss.elastic.co/t/using-constant-multi-match-query-as-filter/67240/2 "2016-12-24T13:18:30Z")

</div>

Closed on December 24, 2016, 1:18pm UTC

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