# Documentation for node level caching and a few caching related questions

**URL:** <https://discuss.elastic.co/t/documentation-for-node-level-caching-and-a-few-caching-related-questions/3162>\
**Category:** Elasticsearch\
**Created:** [July 28, 2010, 5:00am UTC](https://discuss.elastic.co/t/documentation-for-node-level-caching-and-a-few-caching-related-questions/3162 "2010-07-28T05:00:51Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ppearcy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ppearcy/32/980_2.png) [@ppearcy](https://discuss.elastic.co/u/ppearcy)\
**Post date:** [July 28, 2010, 5:00am UTC](https://discuss.elastic.co/t/documentation-for-node-level-caching-and-a-few-caching-related-questions/3162/1 "2010-07-28T05:00:51Z")

</div>

Hi,  
Came across this feature:

> <https://github.com/elastic/elasticsearch/issues/235>

But was not able to find it reflected in the docs. I figured it would  
be in the Node settings.

Also, does this cache hold data for filter queries or other items, as  
well?

While on the topic of caching, I was curious, at what level of  
granularity are filter queries cached?

For example, in the sample query here:  
[http://www.elasticsearch.com/docs/elasticsearch/rest\_api/query\_dsl/and\_filter/](http://www.elasticsearch.com/docs/elasticsearch/rest_api/query_dsl/and_filter/)

Are there two cache objects created for each filter (separate date and  
name caches) or one cache that holds the results of everything  
specified in filters?

How does this work in the case of nested filters? For the example  
below, I'd guess one cached item for each filters grouping, so two  
cached items one for the main filters and the other for the sub-  
filters.

{  
'query' : {  
'constant\_score' : {  
'filter' : {  
'and' : {  
'filters' : [  
{ 'term' : {'data' : 600} },  
{ 'term' : {'symbol' : 'msft'} },  
{ 'or' : {  
'filters' : [  
{'term' : { 'Language' : 'en' } },  
{'term' : { 'Language' : 'fr' } }  
]}}  
]  
}  
}  
}  
}  
}

Thanks!  
Paul

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [July 28, 2010, 5:57am UTC](https://discuss.elastic.co/t/documentation-for-node-level-caching-and-a-few-caching-related-questions/3162/2 "2010-07-28T05:57:32Z")

</div>

On Wed, Jul 28, 2010 at 8:00 AM, Paul [ppearcy@gmail.com](mailto:ppearcy@gmail.com) wrote:

> Hi,  
> Came across this feature:  
> [Memory Store / FS Memory: Create a node level memory store cache and allocator · Issue #235 · elastic/elasticsearch · GitHub](http://github.com/elasticsearch/elasticsearch/issues/issue/235)

This only relates to a case where you store the index in memory. Actually, I  
have not documented that change yet... . It basically pre allocated memory  
for the index to use. Now, this pre-allocated memory is shared between  
shards.

> But was not able to find it reflected in the docs. I figured it would  
> be in the Node settings.
> 
> Also, does this cache hold data for filter queries or other items, as  
> well?

There are different caches for different aspects in elasticsearch. The above  
cache only relates to storing the index in memory.

> While on the topic of caching, I was curious, at what level of  
> granularity are filter queries cached?

Thats a bit complicated when it comes to Lucene. In general, you should  
really care about it. If you are familiar with Lucene, then filters are  
cached on an IndexReader level.

> For example, in the sample query here:
> 
> [http://www.elasticsearch.com/docs/elasticsearch/rest\_api/query\_dsl/and\_filter/](http://www.elasticsearch.com/docs/elasticsearch/rest_api/query_dsl/and_filter/)
> 
> Are there two cache objects created for each filter (separate date and  
> name caches) or one cache that holds the results of everything  
> specified in filters?

It depends on the filter / query (that accepts a filter). In case of  
AndFilter, only the inner filters are cached. The result is not cached as it  
make little sense with the And filter implementation to cache them.

> How does this work in the case of nested filters? For the example  
> below, I'd guess one cached item for each filters grouping, so two  
> cached items one for the main filters and the other for the sub-  
> filters.
> 
> {  
> 'query' : {  
> 'constant\_score' : {  
> 'filter' : {  
> 'and' : {  
> 'filters' :  
> [  
> {  
> 'term' : {'data' : 600} },  
> {  
> 'term' : {'symbol' : 'msft'} },  
> {  
> 'or' : {
> 
> 'filters' : [
> 
> ```
> {'term' : { 'Language' : 'en' } },
> 
> {'term' : { 'Language' : 'fr' } }
> 
> ]}}
> ]
> }
> }
> }
> }
> }
> 
> ```
> 
> Thanks!  
> Paul

---

<div class="post-metadata">

**Author:** ![ppearcy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ppearcy/32/980_2.png) [@ppearcy](https://discuss.elastic.co/u/ppearcy)\
**Post date:** [July 30, 2010, 12:39am UTC](https://discuss.elastic.co/t/documentation-for-node-level-caching-and-a-few-caching-related-questions/3162/3 "2010-07-30T00:39:31Z")

</div>

Hi Shay,  
Many thanks for the details.

If using FS based index storage, are there any caching settings  
available?

Best Regards,  
Paul

On Jul 27, 11:57 pm, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:

> On Wed, Jul 28, 2010 at 8:00 AM, Paul [ppea...@gmail.com](mailto:ppea...@gmail.com) wrote:
> 
> > Hi,  
> > Came across this feature:  
> > [Memory Store / FS Memory: Create a node level memory store cache and allocator · Issue #235 · elastic/elasticsearch · GitHub](http://github.com/elasticsearch/elasticsearch/issues/issue/235)
> 
> This only relates to a case where you store the index in memory. Actually, I  
> have not documented that change yet... . It basically pre allocated memory  
> for the index to use. Now, this pre-allocated memory is shared between  
> shards.
> 
> > But was not able to find it reflected in the docs. I figured it would  
> > be in the Node settings.
> 
> > Also, does this cache hold data for filter queries or other items, as  
> > well?
> 
> There are different caches for different aspects in elasticsearch. The above  
> cache only relates to storing the index in memory.
> 
> > While on the topic of caching, I was curious, at what level of  
> > granularity are filter queries cached?
> 
> Thats a bit complicated when it comes to Lucene. In general, you should  
> really care about it. If you are familiar with Lucene, then filters are  
> cached on an IndexReader level.
> 
> > For example, in the sample query here:
> 
> > [http://www.elasticsearch.com/docs/elasticsearch/rest\_api/query\_dsl/an](http://www.elasticsearch.com/docs/elasticsearch/rest_api/query_dsl/an)...
> 
> > Are there two cache objects created for each filter (separate date and  
> > name caches) or one cache that holds the results of everything  
> > specified in filters?
> 
> It depends on the filter / query (that accepts a filter). In case of  
> AndFilter, only the inner filters are cached. The result is not cached as it  
> make little sense with the And filter implementation to cache them.
> 
> > How does this work in the case of nested filters? For the example  
> > below, I'd guess one cached item for each filters grouping, so two  
> > cached items one for the main filters and the other for the sub-  
> > filters.
> 
> > {  
> > 'query' : {  
> > 'constant\_score' : {  
> > 'filter' : {  
> > 'and' : {  
> > 'filters' :  
> > [  
> > {  
> > 'term' : {'data' : 600} },  
> > {  
> > 'term' : {'symbol' : 'msft'} },  
> > {  
> > 'or' : {
> 
> > 'filters' : [
> 
> > ```
> > {'term' : { 'Language' : 'en' } },
> > 
> > ```
> 
> > ```
> > {'term' : { 'Language' : 'fr' } }
> > 
> > ```
> 
> > ```
> > ]}}
> > ]
> > }
> > }
> > }
> > }
> > }
> > 
> > ```
> 
> > Thanks!  
> > Paul

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [July 30, 2010, 11:24am UTC](https://discuss.elastic.co/t/documentation-for-node-level-caching-and-a-few-caching-related-questions/3162/4 "2010-07-30T11:24:17Z")

</div>

In elasticsearch, there are two more cached, the first is the filter cache,  
and the second is the what I call field data cache (field data is used when  
sorting, faceting, or using scripts). It uses JVM capabilities to cache, so  
its not like an LRU where you would configure the number of cache entries,  
eviction strategy and so on. The only option is to disable it, or choose  
between weak and soft cache.

-shay.banon

On Fri, Jul 30, 2010 at 3:39 AM, Paul [ppearcy@gmail.com](mailto:ppearcy@gmail.com) wrote:

> Hi Shay,  
> Many thanks for the details.
> 
> If using FS based index storage, are there any caching settings  
> available?
> 
> Best Regards,  
> Paul
> 
> On Jul 27, 11:57 pm, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:
> 
> > On Wed, Jul 28, 2010 at 8:00 AM, Paul [ppea...@gmail.com](mailto:ppea...@gmail.com) wrote:
> > 
> > > Hi,  
> > > Came across this feature:  
> > > [Memory Store / FS Memory: Create a node level memory store cache and allocator · Issue #235 · elastic/elasticsearch · GitHub](http://github.com/elasticsearch/elasticsearch/issues/issue/235)
> > 
> > This only relates to a case where you store the index in memory.  
> > Actually, I  
> > have not documented that change yet... . It basically pre allocated  
> > memory  
> > for the index to use. Now, this pre-allocated memory is shared between  
> > shards.
> > 
> > > But was not able to find it reflected in the docs. I figured it would  
> > > be in the Node settings.
> > 
> > > Also, does this cache hold data for filter queries or other items, as  
> > > well?
> > 
> > There are different caches for different aspects in elasticsearch. The  
> > above  
> > cache only relates to storing the index in memory.
> > 
> > > While on the topic of caching, I was curious, at what level of  
> > > granularity are filter queries cached?
> > 
> > Thats a bit complicated when it comes to Lucene. In general, you should  
> > really care about it. If you are familiar with Lucene, then filters are  
> > cached on an IndexReader level.
> > 
> > > For example, in the sample query here:
> > 
> > > [http://www.elasticsearch.com/docs/elasticsearch/rest\_api/query\_dsl/an](http://www.elasticsearch.com/docs/elasticsearch/rest_api/query_dsl/an).  
> > > ..
> > 
> > > Are there two cache objects created for each filter (separate date and  
> > > name caches) or one cache that holds the results of everything  
> > > specified in filters?
> > 
> > It depends on the filter / query (that accepts a filter). In case of  
> > AndFilter, only the inner filters are cached. The result is not cached as  
> > it  
> > make little sense with the And filter implementation to cache them.
> > 
> > > How does this work in the case of nested filters? For the example  
> > > below, I'd guess one cached item for each filters grouping, so two  
> > > cached items one for the main filters and the other for the sub-  
> > > filters.
> > 
> > > {  
> > > 'query' : {  
> > > 'constant\_score' : {  
> > > 'filter' : {  
> > > 'and' : {
> 
> 'filters' :
> 
> > > [
> 
> {
> 
> > > 'term' : {'data' : 600} },
> 
> {
> 
> > > 'term' : {'symbol' : 'msft'} },
> 
> {
> 
> > > 'or' : {
> > 
> > > 'filters' : [
> > 
> > > ```
> > > {'term' : { 'Language' : 'en' } },
> > > 
> > > ```
> > 
> > > ```
> > > {'term' : { 'Language' : 'fr' } }
> > > 
> > > ```
> > 
> > > ```
> > > ]}}
> > > 
> > > ```
> 
> ]
> 
> > > ```
> > > }
> > > }
> > > }
> > > }
> > > }
> > > 
> > > ```
> > 
> > > Thanks!  
> > > Paul

---

<div class="post-metadata">

**Author:** ![otisg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/otisg/32/492_2.png) [@otisg](https://discuss.elastic.co/u/otisg)\
**Post date:** [July 30, 2010, 3:11pm UTC](https://discuss.elastic.co/t/documentation-for-node-level-caching-and-a-few-caching-related-questions/3162/5 "2010-07-30T15:11:18Z")

</div>

Hi Shay,

On Jul 30, 7:24 am, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:

> In elasticsearch, there are two more cached, the first is the filter cache,  
> and the second is the what I call field data cache (field data is used when  
> sorting, faceting, or using scripts). It uses JVM capabilities to cache, so  
> its not like an LRU where you would configure the number of cache entries,  
> eviction strategy and so on. The only option is to disable it, or choose  
> between weak and soft cache.

I imagine the filter cache is actually ES-specific code. Is the field  
data cache also ES-specific, or are you referring to Lucene's  
FieldCache?

## Thanks, Otis

Sematext :: [http://sematext.com/](http://sematext.com/) :: Solr - Lucene - Nutch  
Lucene ecosystem search :: [http://search-lucene.com/](http://search-lucene.com/)

> -shay.banon
> 
> On Fri, Jul 30, 2010 at 3:39 AM, Paul [ppea...@gmail.com](mailto:ppea...@gmail.com) wrote:
> 
> > Hi Shay,  
> > Many thanks for the details.
> 
> > If using FS based index storage, are there any caching settings  
> > available?
> 
> > Best Regards,  
> > Paul
> 
> > On Jul 27, 11:57 pm, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:
> > 
> > > On Wed, Jul 28, 2010 at 8:00 AM, Paul [ppea...@gmail.com](mailto:ppea...@gmail.com) wrote:
> > > 
> > > > Hi,  
> > > > Came across this feature:  
> > > > [Memory Store / FS Memory: Create a node level memory store cache and allocator · Issue #235 · elastic/elasticsearch · GitHub](http://github.com/elasticsearch/elasticsearch/issues/issue/235)
> 
> > > This only relates to a case where you store the index in memory.  
> > > Actually, I  
> > > have not documented that change yet... . It basically pre allocated  
> > > memory  
> > > for the index to use. Now, this pre-allocated memory is shared between  
> > > shards.
> 
> > > > But was not able to find it reflected in the docs. I figured it would  
> > > > be in the Node settings.
> 
> > > > Also, does this cache hold data for filter queries or other items, as  
> > > > well?
> 
> > > There are different caches for different aspects in elasticsearch. The  
> > > above  
> > > cache only relates to storing the index in memory.
> 
> > > > While on the topic of caching, I was curious, at what level of  
> > > > granularity are filter queries cached?
> 
> > > Thats a bit complicated when it comes to Lucene. In general, you should  
> > > really care about it. If you are familiar with Lucene, then filters are  
> > > cached on an IndexReader level.
> 
> > > > For example, in the sample query here:
> 
> > > > [http://www.elasticsearch.com/docs/elasticsearch/rest\_api/query\_dsl/an](http://www.elasticsearch.com/docs/elasticsearch/rest_api/query_dsl/an).  
> > > > ..
> 
> > > > Are there two cache objects created for each filter (separate date and  
> > > > name caches) or one cache that holds the results of everything  
> > > > specified in filters?
> 
> > > It depends on the filter / query (that accepts a filter). In case of  
> > > AndFilter, only the inner filters are cached. The result is not cached as  
> > > it  
> > > make little sense with the And filter implementation to cache them.
> 
> > > > How does this work in the case of nested filters? For the example  
> > > > below, I'd guess one cached item for each filters grouping, so two  
> > > > cached items one for the main filters and the other for the sub-  
> > > > filters.
> 
> > > > {  
> > > > 'query' : {  
> > > > 'constant\_score' : {  
> > > > 'filter' : {  
> > > > 'and' : {
> 
> > 'filters' :
> > 
> > > > [
> 
> > {
> > 
> > > > 'term' : {'data' : 600} },
> 
> > {
> > 
> > > > 'term' : {'symbol' : 'msft'} },
> 
> > {
> > 
> > > > 'or' : {
> 
> > > > 'filters' : [
> 
> > > > ```
> > > > {'term' : { 'Language' : 'en' } },
> > > > 
> > > > ```
> 
> > > > ```
> > > > {'term' : { 'Language' : 'fr' } }
> > > > 
> > > > ```
> 
> > > > ```
> > > > ]}}
> > > > 
> > > > ```
> 
> > ]
> > 
> > > > ```
> > > > }
> > > > }
> > > > }
> > > > }
> > > > }
> > > > 
> > > > ```
> 
> > > > Thanks!  
> > > > Paul

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [July 30, 2010, 3:52pm UTC](https://discuss.elastic.co/t/documentation-for-node-level-caching-and-a-few-caching-related-questions/3162/6 "2010-07-30T15:52:37Z")

</div>

The field data cache is elasticsearch specific, it replaces Lucene  
FieldCache, but serves similar purpose (with extended functionality) with  
the ability to use it for other cases like facets and scripts. I tried to  
get some of the mentioned enhancements to Lucene but got pushed back (like  
using concurrent soft map).

-shay.banon

On Fri, Jul 30, 2010 at 6:11 PM, Otis [otis.gospodnetic@gmail.com](mailto:otis.gospodnetic@gmail.com) wrote:

> Hi Shay,
> 
> On Jul 30, 7:24 am, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:
> 
> > In elasticsearch, there are two more cached, the first is the filter  
> > cache,  
> > and the second is the what I call field data cache (field data is used  
> > when  
> > sorting, faceting, or using scripts). It uses JVM capabilities to cache,  
> > so  
> > its not like an LRU where you would configure the number of cache  
> > entries,  
> > eviction strategy and so on. The only option is to disable it, or choose  
> > between weak and soft cache.
> 
> I imagine the filter cache is actually ES-specific code. Is the field  
> data cache also ES-specific, or are you referring to Lucene's  
> FieldCache?
> 
> ## Thanks, Otis
> 
> Sematext :: [http://sematext.com/](http://sematext.com/) :: Solr - Lucene - Nutch  
> Lucene ecosystem search :: [http://search-lucene.com/](http://search-lucene.com/)
> 
> > -shay.banon
> > 
> > On Fri, Jul 30, 2010 at 3:39 AM, Paul [ppea...@gmail.com](mailto:ppea...@gmail.com) wrote:
> > 
> > > Hi Shay,  
> > > Many thanks for the details.
> > 
> > > If using FS based index storage, are there any caching settings  
> > > available?
> > 
> > > Best Regards,  
> > > Paul
> > 
> > > On Jul 27, 11:57 pm, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:
> > > 
> > > > On Wed, Jul 28, 2010 at 8:00 AM, Paul [ppea...@gmail.com](mailto:ppea...@gmail.com) wrote:
> > > > 
> > > > > Hi,  
> > > > > Came across this feature:  
> > > > > [Memory Store / FS Memory: Create a node level memory store cache and allocator · Issue #235 · elastic/elasticsearch · GitHub](http://github.com/elasticsearch/elasticsearch/issues/issue/235)
> > 
> > > > This only relates to a case where you store the index in memory.  
> > > > Actually, I  
> > > > have not documented that change yet... . It basically pre allocated  
> > > > memory  
> > > > for the index to use. Now, this pre-allocated memory is shared  
> > > > between  
> > > > shards.
> > 
> > > > > But was not able to find it reflected in the docs. I figured it  
> > > > > would  
> > > > > be in the Node settings.
> > 
> > > > > Also, does this cache hold data for filter queries or other items,  
> > > > > as  
> > > > > well?
> > 
> > > > There are different caches for different aspects in elasticsearch.  
> > > > The  
> > > > above  
> > > > cache only relates to storing the index in memory.
> > 
> > > > > While on the topic of caching, I was curious, at what level of  
> > > > > granularity are filter queries cached?
> > 
> > > > Thats a bit complicated when it comes to Lucene. In general, you  
> > > > should  
> > > > really care about it. If you are familiar with Lucene, then filters  
> > > > are  
> > > > cached on an IndexReader level.
> > 
> > > > > For example, in the sample query here:
> > 
> > > > >
> 
> [http://www.elasticsearch.com/docs/elasticsearch/rest\_api/query\_dsl/an](http://www.elasticsearch.com/docs/elasticsearch/rest_api/query_dsl/an).
> 
> > > ..
> > 
> > > > > Are there two cache objects created for each filter (separate date  
> > > > > and  
> > > > > name caches) or one cache that holds the results of everything  
> > > > > specified in filters?
> > 
> > > > It depends on the filter / query (that accepts a filter). In case of  
> > > > AndFilter, only the inner filters are cached. The result is not  
> > > > cached as  
> > > > it  
> > > > make little sense with the And filter implementation to cache them.
> > 
> > > > > How does this work in the case of nested filters? For the example  
> > > > > below, I'd guess one cached item for each filters grouping, so two  
> > > > > cached items one for the main filters and the other for the sub-  
> > > > > filters.
> > 
> > > > > {  
> > > > > 'query' : {  
> > > > > 'constant\_score' : {  
> > > > > 'filter' : {  
> > > > > 'and' : {
> > 
> > > 'filters' :
> > > 
> > > > > [
> > 
> > > {
> > > 
> > > > > 'term' : {'data' : 600} },
> > 
> > > {
> > > 
> > > > > 'term' : {'symbol' : 'msft'} },
> > 
> > > {
> > > 
> > > > > 'or' : {
> > 
> > > > > 'filters' : [
> > 
> > > > > ```
> > > > > {'term' : { 'Language' : 'en' } },
> > > > > 
> > > > > ```
> > 
> > > > > ```
> > > > > {'term' : { 'Language' : 'fr' } }
> > > > > 
> > > > > ```
> > 
> > > > > ```
> > > > > ]}}
> > > > > 
> > > > > ```
> > 
> > > ]
> > > 
> > > > > ```
> > > > > }
> > > > > }
> > > > > }
> > > > > }
> > > > > }
> > > > > 
> > > > > ```
> > 
> > > > > Thanks!  
> > > > > Paul

---

<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, 4:21am UTC](https://discuss.elastic.co/t/documentation-for-node-level-caching-and-a-few-caching-related-questions/3162/7 "2017-07-06T04:21:22Z")

</div>


