Elasticsearch index.refresh_interval Setting

The index.refresh_interval setting in Elasticsearch controls how frequently the index is refreshed, making newly indexed documents available for search. This setting directly impacts the trade-off between indexing throughput and near real-time search visibility.

  • Default value: "1s" (1 second)
  • Possible values: Time value (e.g., "1s", "30s", "5m") or "-1" to disable automatic refreshing
  • Recommendations: Adjust based on your specific use case and requirements for search latency vs. indexing performance

The refresh operation in Elasticsearch makes recent changes to the index visible to search. While a shorter refresh interval provides more up-to-date search results, it can impact indexing performance due to the overhead of frequent refreshes.

Example

To change the refresh interval to 30 seconds for an index named "my_index":

PUT /my_index/_settings
{
  "index": {
    "refresh_interval": "30s"
  }
}

This change might be desirable in scenarios where you prioritize indexing throughput over immediate search visibility, such as bulk indexing operations or log ingestion.

Common Issues and Misuses

  • Setting too short an interval can lead to performance degradation during heavy indexing loads
  • Setting too long an interval can result in delayed visibility of new documents in search results
  • Disabling refreshes entirely (-1) without manual management can lead to excessive memory usage

Do's and Don'ts

Do:

  • Adjust the refresh interval based on your specific use case and performance requirements
  • Monitor the impact of changes to this setting on both indexing and search performance
  • Consider using longer intervals for bulk indexing operations

Don't:

  • Set extremely short intervals (e.g., milliseconds) without careful consideration of the performance impact
  • Forget to re-enable automatic refreshing after bulk operations if you've disabled it
  • Ignore this setting when troubleshooting performance issues related to indexing or search latency

Frequently Asked Questions

Q: How does index.refresh_interval affect indexing performance?
A: A longer refresh interval can improve indexing performance by reducing the frequency of refresh operations, allowing more documents to be indexed between refreshes.

Q: Can I change the refresh_interval for an existing index?
A: Yes, you can dynamically update the refresh_interval for an existing index using the Update Index Settings API.

Q: What happens if I set index.refresh_interval to -1?
A: Setting it to -1 disables automatic refreshing. New documents will not be visible in search results until a manual refresh is performed or the index is closed and reopened.

Q: How does index.refresh_interval relate to near real-time search?
A: The refresh interval determines the maximum delay between when a document is indexed and when it becomes visible in search results, directly impacting the "near real-time" aspect of Elasticsearch.

Q: Should I use different refresh intervals for different indices?
A: Yes, you can and often should use different refresh intervals for different indices based on their specific use cases, indexing rates, and search latency requirements.

Pulse - Elasticsearch Operations Done Right

Stop googling errors and staring at dashboards.

Free Trial

Subscribe to the Pulse Newsletter

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