What kind of filters are really cached?

Hi,
I am building queries so that i can take advantage of query caching.
I need to know, how to write a filter so that it can be cached.
Can someone please help me if the below will be cached ?

{
	"query": {
		"bool": {
			"must": [
				// Some queries
			],
			"filter": [
				{
					"term": {
						"type": {
							"value": "Cars",
							"boost": 1.0
						}
					}
				}
			]
		}
	}
}

When i run the above my cached index with same documents and cache disabled index with same documents gives exactly same throughput. The queryCache size goes upto 50Mb.

I am not able to understand why my caching and its utilization is not working.
Please help !

Why do you think cache is not working? I mean can you give details about your test?

I have two separate ES clusters:
Cluster A - "queries.cache.enable=false" - 35million docs
Cluster B - "queries.cache.enable=true" - 35million docs

The only difference in A and B is cache, rest everything is exactly same.

Test -
I have test queries like above of ~3lakh records. I run it against A and then B.
The throughput i get is exactly same.

Cached details:
I can see data cached on A is 0kb and on B is 100mb. So some queries are getting cached on B for sure.

Query:
Why is ES not utilizing the cache and giving me better performance on B ?

Most of the cache used is the file system cache. @jpountz can tell more on this topic hopefully.

Thanks. I thought it was in-memory cache as it would use some part of assigned heap. Not sure though.

@jpountz, any help would be appreciated. We are stuck on a important issue on production.

There are several caches, a shard request cache, a filter cache, plus Elasticsearch heavily relies on the OS cache.

Term filters are never cached, for a good reason: the inverted index is already a cache of hits for every possible term. So if all your queries look like the one you shared, it's expected that the query cache doesn't help.

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