mjalajel
mjalajel

Reputation: 2201

ElasticSearch refresh effect on cache

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?

Upvotes: 5

Views: 2046

Answers (1)

Alex Brasetvik
Alex Brasetvik

Reputation: 11754

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:

Upvotes: 5

Related Questions