ElasticSearch refresh effect on cache
caching, elasticsearch
Solution
A refresh causes new documents to be visible for searching. This happens by writing a new index segment. A new segment can also be made by merging old large ones.
Filter- and field caches are managed per segment, since a segment is immutable. You can use the warmer APIs to ensure caches are pre-warmed before being made available for search. If not, then parts of the cache is essentially "cleared".
A `flush` in Elasticsearch terms actually calls a Lucene `commit`. This is quite more expensive.
If you have a write heavy app, you probably want to increase the refresh interval to get better indexing throughput.
There's some more details about these things in these two articles:
- Elasticsearch from the Bottom Up, Part 1
- Elasticsearch Refresh Interval vs Indexing Performance
Problem
In ElasticSearch, does calling Refresh or Flush clear field and filter cache? I have a write-heavy application, is it better to run refresh or flush, or is there any better approach for this?