AI Hints
Home›Elasticsearch Tutorial›Shards, Health and Performance
Elasticsearch · Lesson 108 of 120

Refresh and Performance

Near real time.

⏱ 2 min read▶ Video at 1:41:51🎓 Free
Watch this lesson in the Elasticsearch courseWatch on YouTube ↗Full Elasticsearch course

Elasticsearch is near real time. A new document becomes searchable after a refresh, which happens every second by default. That one second matters for both tests and speed.

  • Index a doc
  • Wait for refresh
  • Then searchable

Before and after refresh

We turn off automatic refresh, and index a document. Searching finds nothing yet. After a manual refresh, it's found. Run it. Zero, then one.

Dev Tools Consoletext
PUT notes?filter_path=acknowledged
{ "settings": { "refresh_interval": "-1" } }

POST notes/_doc?filter_path=result
{ "text": "new trail map" }

GET notes/_count?filter_path=count
POST notes/_refresh?filter_path=_shards.failed
GET notes/_count?filter_path=count
Output
# PUT notes 200 OK
{"acknowledged": true}

# POST notes/_doc 201 Created
{"result": "created"}

# GET notes/_count 200 OK
{"count": 0}

# POST notes/_refresh 200 OK
{"_shards": {"failed": 0}}

# GET notes/_count 200 OK
{"count": 1}

Speed tips

For big loads, use bulk, and set the refresh interval to thirty seconds or off, then back. Set replicas to zero during the load, then add them. Avoid refresh true on every request. And use filters, which are cached.

keyvalue
Bulknot one by one
refresh_interval30s or -1 for loads
Replicas0 during load
Filterscached

Summary

Documents become searchable after a refresh, about one second by default, and you can tune it for speed. Next, data streams and lifecycle policies.

Key takeaways
  • Refresh
  • Near real time
  • Tune for loads
Next up: Data Streams and ILM — time series data