Optimise Elasticsearch queries with AI
Locate costly clauses using the actual search profile and mapping, then compare a focused rewrite with the original. Preserve the result set and scoring where they matter.
Optimise Elasticsearch queries with AI when a slow search has several plausible explanations. The elasticsearch-query-optimization skill examines the profile tree, checks the mapping for each field and separates query costs from expensive aggregations. A filter on an exact status field has different requirements from a scored text match.
Before rewriting a production query, use representative inputs and keep the original response available. A faster candidate that changes which orders appear is not an equivalent result. Profiling also adds overhead, so use it to understand relative work rather than quoting its timings as end-to-end customer latency.
What it does
- Locate the largest contributor in a query profile.
- Check exact-value and analysed-text field types.
- Review unnecessary scoring of filters.
- Compare candidate results against the original request.
- Identify when an aggregation needs separate investigation.
Install and use
- Install the skill and configure official elastic CLI 0.2 or later with authorised search and profile access to Elasticsearch 8.x, 9.x or a supported serverless deployment.
- Ask, “Profile this orders query and identify the dominant clause. Confirm the mappings before proposing one change to compare.”
- Run a scoped comparison with representative data. Review matching documents, ranking requirements and the cost of profiling itself.
FAQ
Source
Made by Elastic. Original skill: elasticsearch-query-optimization, published on GitHub under the Apache-2.0 licence.
View on GitHub