# Term complexity and filter caching

**URL:** <https://discuss.elastic.co/t/term-complexity-and-filter-caching/20466>\
**Category:** Elasticsearch\
**Created:** [October 28, 2014, 4:59pm UTC](https://discuss.elastic.co/t/term-complexity-and-filter-caching/20466 "2014-10-28T16:59:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![smonasco\_2](https://avatars.discourse-cdn.com/v4/letter/s/848f3c/32.png) [@smonasco\_2](https://discuss.elastic.co/u/smonasco_2)\
**Post date:** [October 28, 2014, 4:59pm UTC](https://discuss.elastic.co/t/term-complexity-and-filter-caching/20466/1 "2014-10-28T16:59:36Z")

</div>

Hi peeps,

Leaf level filter cache is nice, but caching complex filters is better if  
you can get some hit ratio.

We have some items (querystrings that may become bool filters later) with  
over 50 terms (sometimes hundreds) that get reused often. We essentially  
aggregate financial research for hundreds of sites, each of which have only  
paid for certain data and this is the primary case for these complex and  
highly reused queries.

However, we are looking at adding in some leaf level filter caching on  
other items. Say an industry or a report type. Across fields with small  
permutation and high re-use.

Elasticsearch employs an LRU policy on filter cache.

However, the complex queries with high term complexity and lots of "AND"s  
and "OR"s saves far more time, CPU and memory per use than the leaf level  
caching on something like "reporttype:research" , so I'd like to add some  
weight to the more complex queries when determining what gets evicted.

Thoughts?

--Shannon Monasco

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/e51fafea-d4f3-4bc3-823e-26f9e40dfe89%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/e51fafea-d4f3-4bc3-823e-26f9e40dfe89%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:53am UTC](https://discuss.elastic.co/t/term-complexity-and-filter-caching/20466/2 "2017-07-06T00:53:23Z")

</div>

Closed on July 6, 2017, 12:53am UTC


