# Control query cache

**URL:** <https://discuss.elastic.co/t/control-query-cache/96997>\
**Category:** Elasticsearch\
**Created:** [August 14, 2017, 4:05pm UTC](https://discuss.elastic.co/t/control-query-cache/96997 "2017-08-14T16:05:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nimrodparasol](https://avatars.discourse-cdn.com/v4/letter/n/94ad74/32.png) [@nimrodparasol](https://discuss.elastic.co/u/nimrodparasol)\
**Post date:** [August 14, 2017, 4:05pm UTC](https://discuss.elastic.co/t/control-query-cache/96997/1 "2017-08-14T16:05:47Z")

</div>

Hi,

I'm using Elasticsearch to index logs of hundreds of thousands of IOT devices.  
I have thousands of customers and each one of them is permitted to query logs of some of the devices.  
To enforce the permissions I used Parent-Child reference by the following model:  
Child - log  
Parent - list of device's permitted customers.  
My problem, Is that queries using "has\_parent" filter are taking a lot of time when not in the query cache.

Is it possible to config elasticsearch so it keep this query always in the cache?  
Is it possible to control which queries get into cache and which not?  
As I understand, queries are cached only if they were executed 5 times out of the 256 last queries. Is there a flag that cache the query no matter what?  
Is it possible to make the Query Cache update eagerly upon refresh?

Assuming the answer to all of the above is "No",  
Is it possible to implement custom cache and integrate it into elasticsearch natively (without the need to fork the project)

Also,  
If you have a better solution for my permissions management I'd be glad to hear 🙂

Thanks,  
Nimrod

---

<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 11, 2017, 4:05pm UTC](https://discuss.elastic.co/t/control-query-cache/96997/2 "2017-09-11T16:05:53Z")

</div>

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