Judy T Raj
Judy T Raj

Reputation: 1844

Why is my elasticsearch query cache empty?

I'm using the elasticsearch version 6.1.1. I've been running queries in the filter context on an index on which I've explicitly enabled query cache. But the query cache is empty. I found a similar case on the elasticsearch discuss forums (https://discuss.elastic.co/t/query-cache-is-empty/84515 ), but it doesn't have a solution listed. As per the documentation here, https://www.elastic.co/guide/en/elasticsearch/reference/current/query-cache.html, the query cache should work for queries run in the filter context.

After I succsefully run this,

curl -XGET 'localhost:9200/_search?pretty' -H 'Content-Type: application/json' -d'
{
  "query": { 
    "bool": { 
      "filter": [ 
        { "term":  { "status": "true" }}
      ]
    }
  }
}
'

This is the query cache stats that I get:

"indices" : {
        "query_cache" : {
          "memory_size" : "0b",
          "memory_size_in_bytes" : 0,
          "total_count" : 0,
          "hit_count" : 0,
          "miss_count" : 0,
          "cache_size" : 0,
          "cache_count" : 0,
          "evictions" : 0
        }
      }

Upvotes: 2

Views: 3118

Answers (1)

chengpohi
chengpohi

Reputation: 14227

There is a bug in 6.x of term filter, it can't be query cached. see:

https://github.com/elastic/elasticsearch/pull/27190

so maybe you can try range filter or exists for query cache. and also your docs need to big enough(I test in 100k documents) for query cache.

Upvotes: 2

Related Questions