0
0
Elasticsearchquery~20 mins

Cache management (query, request, field data) in Elasticsearch - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Cache Mastery in Elasticsearch
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the output of this Elasticsearch query cache stats request?
Given the following request to check query cache statistics, what will be the value of query_cache.memory_size_in_bytes if no queries have been cached yet?
Elasticsearch
GET /_nodes/stats/query_cache
A{"nodes":{"<node_id>":{"indices":{"query_cache":{"memory_size_in_bytes":null}}}}}
B{"nodes":{"<node_id>":{"indices":{"query_cache":{"memory_size_in_bytes":0}}}}}
C{"nodes":{"<node_id>":{"indices":{"query_cache":{"memory_size_in_bytes":1024}}}}}
D{"nodes":{"<node_id>":{"indices":{"query_cache":{"memory_size_in_bytes":-1}}}}}
Attempts:
2 left
💡 Hint
Think about what the cache size would be before any queries are cached.
🧠 Conceptual
intermediate
1:30remaining
Which cache type is cleared when a document is updated in Elasticsearch?
In Elasticsearch, when you update a document, which cache is automatically cleared to ensure fresh results?
AField data cache
BRequest cache
CQuery cache
DShard request cache
Attempts:
2 left
💡 Hint
Think about which cache holds field values used for sorting and aggregations.
Predict Output
advanced
2:00remaining
What is the output of this request cache usage query?
Consider this request to check the request cache stats for an index. What is the value of hit_count if the cache was never used?
Elasticsearch
GET /my_index/_stats/request_cache
A{"_all":{"total":{"request_cache":{"hit_count":1}}}}
B{"_all":{"total":{"request_cache":{"hit_count":-1}}}}
C{"_all":{"total":{"request_cache":{"hit_count":null}}}}
D{"_all":{"total":{"request_cache":{"hit_count":0}}}}
Attempts:
2 left
💡 Hint
If the cache was never hit, the hit count should be zero.
🔧 Debug
advanced
2:30remaining
Why does this query cache not improve performance?
You enabled query cache on an index, but queries are not being cached. Which of the following reasons explains this behavior?
Elasticsearch
GET /my_index/_search
{
  "query": {
    "match_all": {}
  },
  "request_cache": true
}
AThe query cache is disabled by default and must be enabled explicitly per index.
BThe query is not cacheable because it uses a match_all query.
CThe request cache only caches filter context queries, not match queries.
DThe request cache caches only aggregations, not queries.
Attempts:
2 left
💡 Hint
Request cache works only for certain query types.
🚀 Application
expert
3:00remaining
How to reduce field data cache memory usage for a large text field?
You have a large text field used for sorting and aggregations causing high field data cache memory usage. Which approach will reduce memory usage effectively?
AEnable doc_values on the field and disable fielddata.
BIncrease the fielddata cache size limit in Elasticsearch settings.
CDisable the query cache for the index.
DUse the request cache instead of field data cache.
Attempts:
2 left
💡 Hint
Doc_values store field data on disk in a columnar format, reducing heap usage.