How to Improve Elasticsearch Search Performance

How to Improve Elasticsearch Search Performance

Last Updated : January 2021

If you’re suffering from poor search performance, you should run Opster’s Search Log Analyzer. With Opster’s Analyzer, you can easily locate slow searches and understand what led to them adding additional load to your system. You’ll receive customized recommendations for how to improve your search performance. The tool is free and takes just 2 minutes to run.

10 tips on how to reduce Elasticsearch search latency and optimize search performance:

  1. Size parameter

    Assigning a huge value to size parameter causes Elasticsearch to compute vast amounts of hits, which causes severe performance issues. Instead of setting a huge size, you should batch requests in small sizes.

  2. Shards and replicas

    Optimize necessary index settings that play a crucial role in Elasticsearch performance, like the number of shards and replicas. In many cases having more replicas helps improve search performance. Please refer to Opster’s guide on shards and replicas to learn more.

  3. Deleted documents

    Having a large number of deleted documents in the Elasticsearch index also causes search performance issues, as explained in this official document. Force merge API can be used to remove a large number of deleted documents and optimize the shards.

  4. Search filters

    Effective use of filters in Elasticsearch queries can improve search performance dramatically as the filter clauses are 1) cached, and 2) able to reduce the target documents to be searched in the query clause.

  5. Wildcard queries

    Avoid wildcard, especially leading wildcard queries, which causes the entire Elasticsearch index to be scanned. 

  6. Regex and parent-child

    Note that Regex queries and parent-child can cause search latency.

  7. Implementing features

    There are multiple ways to implement a specific feature in Elasticsearch. For example, Autocomplete can be implemented in various styles. Opster’s blog gives a 360-degree view of both functional and non-functional features (especially performance).

  8. Multitude of small shards

    Having many small shards could cause a lot of network calls and threads, which severely impact search performance; please refer to this real-world case study by Opster’s expert on this topic.

  9. Heavy aggregations

    Avoid heavy aggregations that involve unique IDs. Refer to Opster’s  slow logs guide to identify such search slow logs effectively. 

  10. Timeout and terminate

    Timeout param and terminate after param can be useful when executing heavy searches, or when result data is vast. This official guide can help.

Say goodbye to search latency and related downtime – Opster’s Search Gateway transforms the way searches are handled in Elasticsearch.

Aside from gaining deep visibility of searches and the option to group data by users and application, the Gateway provides users with the unique ability to block heavy searches and prevent them from degrading performance and breaking clusters. Learn more about the Search Gateway and book a demo to get started.