Check if elasticsearch query results are coming from cache or not? Check if elasticsearch query results are coming from cache or not? elasticsearch elasticsearch

Check if elasticsearch query results are coming from cache or not?


By default, the requests cache will only cache the results of search requests where size=0, so it will not cache hits, but it will cache hits.total, aggregations, and suggestions.

The request_cache query-string parameter can be used to enable or disable caching on a per-request basis. If set, it overrides the index-level setting:

GET /my_index/_search?request_cache=true{  "size": 0,  "aggs": {    "popular_colors": {      "terms": {        "field": "colors"      }    }  }}

SEE MORE: https://www.elastic.co/guide/en/elasticsearch/reference/current/shard-request-cache.html#_enabling_and_disabling_caching_per_request