# Is there any external implementation to cache a query in elastic?

**URL:** <https://discuss.elastic.co/t/is-there-any-external-implementation-to-cache-a-query-in-elastic/135188>\
**Category:** Elasticsearch\
**Created:** [June 8, 2018, 7:01pm UTC](https://discuss.elastic.co/t/is-there-any-external-implementation-to-cache-a-query-in-elastic/135188 "2018-06-08T19:01:56Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Suryatejreddy](https://avatars.discourse-cdn.com/v4/letter/s/e9bcb4/32.png) [@Suryatejreddy](https://discuss.elastic.co/u/Suryatejreddy)\
**Post date:** [June 8, 2018, 7:01pm UTC](https://discuss.elastic.co/t/is-there-any-external-implementation-to-cache-a-query-in-elastic/135188/1 "2018-06-08T19:01:56Z")

</div>

I am trying to cache a query. so that next time when I do the same query, results from the cache are retrieved.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 8, 2018, 7:20pm UTC](https://discuss.elastic.co/t/is-there-any-external-implementation-to-cache-a-query-in-elastic/135188/2 "2018-06-08T19:20:53Z")

</div>

Filters are cached, not queries. But elasticsearch uses a lot the file system cache.

You should not normally worry about that.

---

<div class="post-metadata">

**Author:** ![Suryatejreddy](https://avatars.discourse-cdn.com/v4/letter/s/e9bcb4/32.png) [@Suryatejreddy](https://discuss.elastic.co/u/Suryatejreddy)\
**Post date:** [June 8, 2018, 7:39pm UTC](https://discuss.elastic.co/t/is-there-any-external-implementation-to-cache-a-query-in-elastic/135188/3 "2018-06-08T19:39:22Z")

</div>

Thanks for your quick response. I have a couple of questions.

1. So filters are cached. for example when you have below query:

GET persons/person/\_search  
{  
"query":{  
"bool":{  
"must":[  
{  
"match":{  
"firstName":"Keith"  
}  
},  
{  
"match":{  
"gender":"M"  
}  
}  
],  
"filter":[  
{  
"range":{  
"dob":{  
"gte":"1920"  
}  
}  
}  
]  
}  
}  
}

How can we cache the filtered context in above query? If exists how should we enable "\_cache":"true"

1. So you mean, the hot indexes are always fast in retrieval because elastic uses file system cache? and we need not implement any caching mechanism explicitly. Elastic can handle caching by default?

Thanks and Regards,  
Surya

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 8, 2018, 7:55pm UTC](https://discuss.elastic.co/t/is-there-any-external-implementation-to-cache-a-query-in-elastic/135188/4 "2018-06-08T19:55:27Z")

</div>

> How can we cache the filtered context in above query?

It's automatically done.

What is the problem you want to solve here?

---

<div class="post-metadata">

**Author:** ![Suryatejreddy](https://avatars.discourse-cdn.com/v4/letter/s/e9bcb4/32.png) [@Suryatejreddy](https://discuss.elastic.co/u/Suryatejreddy)\
**Post date:** [June 8, 2018, 8:04pm UTC](https://discuss.elastic.co/t/is-there-any-external-implementation-to-cache-a-query-in-elastic/135188/5 "2018-06-08T20:04:30Z")

</div>

I wanted to use Elastic Search to store huge amounts of data. My API will be calling Elasticsearch frequently using GET queries. I am now just researching on elastic search caching behavior to analyze the performance of data retrieval.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 8, 2018, 8:06pm UTC](https://discuss.elastic.co/t/is-there-any-external-implementation-to-cache-a-query-in-elastic/135188/6 "2018-06-08T20:06:32Z")

</div>

Just try with defaults. If any problem just ask here and we will help.

---

<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, 2018, 8:19pm UTC](https://discuss.elastic.co/t/is-there-any-external-implementation-to-cache-a-query-in-elastic/135188/7 "2018-07-06T20:19:38Z")

</div>

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