Understanding filter cache and writing warmers to keep filter cache warm


(Siddartha Guthikonda) #1
> {
> 	"query": {
> 		"filtered": {
> 			"filter": {
> 				"and": [{
> 					"bool": {
> 						"must": [{
> 							"term": {
> 								"application.raw": "Application1"
> 							}
> 						}]
> 					}
> 				}, {
> 					"term": {
> 						"metric.raw": "Metric1",
> 						"_cache": false
> 					}
> 				}, {
> 					"nested": {
> 						"path": "tags",
> 						"query": {
> 							"filtered": {
> 								"filter": {
> 									"and": [{
> 										"term": {
> 											"tags.key.raw": "tagkey1",
> 											"_cache": false
> 										}
> 									}, {
> 										"term": {
> 											"tags.value.raw": "tagvalue1",
> 											"_cache": false
> 										}
> 									}]
> 								}
> 							}
> 						}
> 					}
> 				}]
> 			}
> 		}
> 	}
> }

This a sample query for a index with 500M documents. When the cache is cold this takes around 23 sec for the query to complete. When it is cached (when I run the same query more than twice) I get the response within 500 ms which is great. Note that the "metric" field that I am interested in is the value that are in the "Application1" documents.
I want to understand if "application" is the only field that is cached from this query?
Also, is "Application1" is the only value that is cached? What if I change the query to match "Application2" and a different set of nested documents?

How can I write warmers to cache all the applications I have in the index?


(system) #2