# Why is my term aggregation not getting cached into request cache?

**URL:** <https://discuss.elastic.co/t/why-is-my-term-aggregation-not-getting-cached-into-request-cache/117760>\
**Category:** Elasticsearch\
**Created:** [January 31, 2018, 7:50am UTC](https://discuss.elastic.co/t/why-is-my-term-aggregation-not-getting-cached-into-request-cache/117760 "2018-01-31T07:50:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Judy\_Raj](https://avatars.discourse-cdn.com/v4/letter/j/ccd318/32.png) [@Judy\_Raj](https://discuss.elastic.co/u/Judy_Raj)\
**Post date:** [January 31, 2018, 7:50am UTC](https://discuss.elastic.co/t/why-is-my-term-aggregation-not-getting-cached-into-request-cache/117760/1 "2018-01-31T07:50:11Z")

</div>

I've an index on which I've explicitly enabled request cache using the following settings:

```
curl -XPUT 'localhost:9200/index_one?pretty' -H 'Content-Type: application/json' -d'
{
  "settings": {

    "index.requests.cache.enable": "true"
  },
 "mappings": {
    	"type_one": {
      		"properties": {
        		"status": {
          			"type": "keyword"
        		}
     		 }
    	}
  	}

}
'

```

I'm running this aggregation on it, which returns a successfully aggregated bucket.

```
curl -XGET 'localhost:9200/_search?&pretty' -H 'Content-Type: application/json' -d'
{
    "aggs" : {
        "availability" : {
            "terms" : { "field" : "status" }
        }
    }
}
'

```

But my request cache is empty.

```
"request_cache" : {
          "memory_size" : "0b",
          "memory_size_in_bytes" : 0,
          "evictions" : 0,
          "hit_count" : 0,
          "miss_count" : 0
        }

```

According to this link here, request cache ought to be caching aggregations. [https://www.elastic.co/guide/en/elasticsearch/reference/current/shard-request-cache.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/shard-request-cache.html)  
I'm using elasticsearch version 6.1.1

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [January 31, 2018, 8:22am UTC](https://discuss.elastic.co/t/why-is-my-term-aggregation-not-getting-cached-into-request-cache/117760/2 "2018-01-31T08:22:09Z")

</div>

As mentioned in the [shard request cache docs](https://www.elastic.co/guide/en/elasticsearch/reference/6.1/shard-request-cache.html), this caching only happens when you set `size: 0` in your request.

Can you try with that?

---

<div class="post-metadata">

**Author:** ![Judy\_Raj](https://avatars.discourse-cdn.com/v4/letter/j/ccd318/32.png) [@Judy\_Raj](https://discuss.elastic.co/u/Judy_Raj)\
**Post date:** [January 31, 2018, 9:18am UTC](https://discuss.elastic.co/t/why-is-my-term-aggregation-not-getting-cached-into-request-cache/117760/3 "2018-01-31T09:18:53Z")

</div>

Yup! That works. Thank you.

---

<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:** [February 28, 2018, 9:19am UTC](https://discuss.elastic.co/t/why-is-my-term-aggregation-not-getting-cached-into-request-cache/117760/4 "2018-02-28T09:19:03Z")

</div>

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