Loading...
Loading...
Diagnose slow Elasticsearch Query DSL searches and propose measured fixes. Use when a search is slow, profile output shows an expensive clause, exact-match filters sit in scoring context, or leading wildcards dominate latency. Ground every recommendation in search profiling — move non-scoring clauses to filter context, eliminate leading wildcards, and re-profile to confirm improvement.
npx skill4agent add elastic/agent-skills elasticsearch-query-optimizationelasticelasticGET /GET /_cat/indicesGET /{index}/_mappingGET /{index}/_settings/index.modePOST /_queryelasticScope: Query DSL searches via. This skill does not migrate queries to ES|QL — it optimizes the existing bool/match/term/wildcard structure the user already runs.POST /{index}/_searchGround rule: Never recommend "add shards" or "scale hardware" as the primary fix when the profile names a specific clause (for exampleat ~3.8s). Fix the query first; infrastructure changes require evidence the query is already optimal.WildcardQuery
GET /logs-*GET /_cat/indicesPOST /{index}/_search"profile": truetookprofile.shards[].searches[].querytime_in_nanosTermQueryPointRangeQueryMatchNoDocsQuerymustfilterWildcardQuery*message:*timeout*MatchQuerytextaggregationtypedescriptiontime_in_nanosbreakdownnext_docGET /{index}/_mappingtermtermsfilterkeywordtermtextservice.keywordmatchmatch_phrasetextwildcardkeywordwildcard*mustfiltertermtermsrangematchmustmatchbool.filterfilter_scorebool.mustmatch{
"query": {
"bool": {
"filter": [{ "term": { "status": "active" } }, { "term": { "tenant_id": "acme" } }],
"must": [{ "match": { "description": "wireless keyboard" } }]
}
}
}WildcardQuerydescriptionmessage:*timeout*next_doc*| Intent | Preferred rewrite |
|---|---|
| Full-text substring in logs | |
| Literal substring on keyword | |
Prefix only ( | |
{ "match": { "service": "checkout" } }filterterm{
"query": {
"bool": {
"filter": [{ "term": { "service.keyword": "checkout" } }],
"must": [{ "match": { "message": "timeout" } }]
}
}
}serviceservice.keywordwildcardmatchPOST /{index}/_validate/query?explain=truePOST /{index}/_search"profile": truetooktime_in_nanostooktypedescriptiontime_in_nanosWildcardQuerymessage:*timeout*next_docGET /{index}/_mappingtookmatchwildcardmustmatchmatch_phrasewildcardtimeout*wildcardmustbool.musttermstatustermtenant_idmatchdescriptionTermQueryMatchQuerytermfiltermatchmuststatustenant_idkeywordwildcardmessage:*timeout*matchservicemustWildcardQuery*matchmessagefiltertermWildcardQuery| HTTP API (shorthand) | |
|---|---|
| |
| |
| |
| |
| |
"profile": true--profile true