liveBook · Manning

Refresh interval

As explained in Elasticsearch in Action, Second Edition

A refresh interval is the configured time between automatic refresh operations that make newly indexed documents searchable.

A refresh interval is the time Elasticsearch waits between refresh operations that make newly indexed documents searchable. The default interval is one second, but longer intervals can reduce repeated disk I/O during heavy indexing. section 5.1.2 section 15.2.3

Choose the setting according to how quickly new documents must appear in search:

  • Set refresh_interval to 60s or 1m when indexing can tolerate a one-minute delay; documents indexed during that period are not immediately searchable. section 5.1.3 section 15.2.3
  • Set refresh_interval to -1 before a large migration or bulk load to disable automatic refresh and reduce resource-intensive disk I/O. section 15.2.3
  • Restore the interval afterward, or call POST <index>/_refresh, so indexed documents become available for searching. section 5.1.3 section 15.2.3

Bulk-loading a movie index

Set a longer interval while loading many movie documents, then restore normal refreshing when the load finishes. For individual writes, refresh=false uses the interval; refresh=true makes the document searchable immediately; refresh=wait_for blocks until a refresh completes. section 5.1.3 section 15.2.3

Listing 5.7 Setting a custom refresh interval
PUT movies/_settings
{
  "index":{
    "refresh_interval":"60s"
  }
}

Inspect the REST request for setting a 60-second refresh interval on the movies index. section 5.1.3

How Elasticsearch in Action, Second Edition covers it

How deep it goes
Explains settings, client overrides, search visibility, disk I/O, in-memory buffers, and Lucene segments.
Examples
Uses movies and programming-books indexes, one-minute intervals, disabled refresh, forced refresh, and refresh query parameters.
What it assumes
Assumes basic indexing and searching knowledge while explaining refresh visibility from in-memory buffers through searchable segments.
What you can do after
Operate/configure refresh timing, force visibility, defer visibility, and verify the effects through indexing and search requests.
How it connects
Connects refresh intervals to Elasticsearch indexing, Lucene segments, disk I/O, CRUD APIs, bulk requests, and search visibility.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Elasticsearch in Action, Second Edition. The section links point to the parts of the book it draws on.