Elasticsearch Performance
4 min read Quiz at the end
Speed up ES with filter context, bulk API, adjusted refresh interval, and proper shard sizing.
Elasticsearch Performance Tips
- Use filter context — filters are cached and skip scoring (use for exact matches)
- Avoid wildcard at start — *term is very slow; use ngram analyser instead
- Size 0 for aggregations — set "size":0 when you only need aggregation results
- Use bulk API — batch inserts are 20x faster than individual indexing
- Refresh interval — set index.refresh_interval to 30s during bulk load
- disable _source compression — enable compression to reduce storage
- Shard sizing — aim for 10-50GB per shard; too many shards hurts performance
# Disable refresh during bulk indexing
PUT /myindex/_settings
{ "index": { "refresh_interval": "-1" } }
# Re-enable after load
PUT /myindex/_settings
{ "index": { "refresh_interval": "1s" } }