Elasticsearch index.requests.cache.enable Setting

Pulse - Elasticsearch Operations Done Right

On this page

Example Common Issues and Misuses Do's and Don'ts Frequently Asked Questions

The index.requests.cache.enable setting in Elasticsearch controls whether the request cache is enabled for an index. This cache stores the results of search requests, allowing for faster retrieval of frequently accessed data.

  • Default Value: true
  • Possible Values: true or false
  • Recommendations: Keep enabled for indices with frequent, similar queries. Disable for indices with rapidly changing data or unique queries.

The request cache is particularly useful for indices that receive repeated, similar queries. It can significantly improve performance by serving cached results instead of re-executing the query. However, for indices with rapidly changing data or those that rarely see repeated queries, disabling the cache might be more beneficial.

Example

To disable the request cache for an index named "my_index":

PUT /my_index/_settings
{
  "index.requests.cache.enable": false
}

You might want to change this setting if:

  • Your index data changes frequently, and cached results quickly become stale.
  • You're experiencing high memory usage due to caching.
  • Most of your queries are unique and don't benefit from caching.

Common Issues and Misuses

  • Enabling the cache for indices with rapidly changing data, leading to stale results.
  • Disabling the cache for indices with frequent, similar queries, missing out on performance benefits.
  • Not monitoring cache hit rates and sizes, potentially wasting resources.

Do's and Don'ts

Do's:

  • Enable for indices with stable data and repetitive queries.
  • Monitor cache hit rates to ensure it's beneficial.
  • Adjust cache size based on your index size and query patterns.

Don'ts:

  • Don't enable for indices where data freshness is critical.
  • Don't ignore cache statistics; they provide valuable insights into its effectiveness.
  • Don't assume caching is always beneficial; test performance with and without it.

Frequently Asked Questions

Q: How does the request cache differ from the query cache?
A: The request cache stores entire search results, while the query cache stores only certain parts of queries. The request cache is more comprehensive but can consume more memory.

Q: Can I enable/disable the request cache for specific queries?
A: Yes, you can use the ?request_cache=true/false parameter in your query URL to override the index-level setting for individual requests.

Q: How can I monitor the effectiveness of the request cache?
A: Use Elasticsearch's stats API to check cache hit rates, evictions, and memory usage. High hit rates indicate the cache is beneficial.

Q: Does the request cache work with aggregations?
A: Yes, the request cache can store results of queries that include aggregations, which can significantly improve performance for complex aggregations.

Q: How often is the request cache invalidated?
A: Cache entries are automatically invalidated when the underlying data changes or when the cache reaches its size limit and needs to evict entries.

Subscribe to the Pulse Newsletter

Get early access to new Pulse features, insightful blogs & exclusive events , webinars, and workshops.