Prompt

How do I troubleshoot slow log searches in Elasticsearch?

Technology / Observability1 observationLast seen Oct 28, 2026

Latest observation

Oct 28, 2026OpenAI APIWeb search: off

Here’s a practical way to troubleshoot slow log searches in Elasticsearch, from quickest checks to deeper root-cause analysis.

1) Confirm where the slowness is

First determine whether the delay is in:

  • Elasticsearch query execution
  • Network / client-side latency
  • Dashboard/app rendering
  • A specific index or time range

Useful checks:

  • Run the same search directly in Elasticsearch with curl or Kibana Dev Tools.
  • Compare:
    • took in the response
    • client-observed latency
  • Try a very small time range and a broad one.

If took is low but the app is slow, the issue may not be Elasticsearch.


2) Use the Search Profiler / _profile

If a search is slow, inspect what Elasticsearch is spending time on.

Search Profiler

In Kibana:

  • Dev Tools / Search Profiler
  • Paste the query
  • Look for:
    • expensive match_all + heavy sort/aggregation
    • high-cost scripts
    • large terms aggregations
    • expensive wildcard/regex queries

_profile

Example:

GET my-index/_search
{
  "profile": true,
  "query": {
    "bool": {
      "must": [
        { "match": { "message": "error" } }
      ]
    }
  }
}

Look for:

  • Which query clause is slow
  • Which shard is slow
  • Whether time is spent in scoring, filtering, or aggregations

3) Check whether the query is forcing full scans

Common causes of slow searches:

Expensive query patterns

  • Leading wildcard:
    • *error
  • Regex queries
  • Very broad time range
  • query_string with many fields
  • Sorting on fields not optimized for sorting
  • Large from pagination values
  • Heavy aggregations on high-cardinality fields

Better alternatives

  • Use prefix or analyzed search instead of leading wildcards
  • Use filters (bool.filter) for non-scoring clauses
  • Use search_after instead of deep pagination
  • Limit fields returned with _source filtering
  • Avoid huge terms aggregations unless needed

4) Inspect shard health and distribution

Slow searches often happen when shards are too many, too large, or unbalanced.

Check:

GET _cat/shards?v
GET _cat/indices?v
GET _cluster/health

Watch for:

  • Hot shards on one node
  • Too many shards
  • Very large shards
  • Unassigned or relocating shards

General guidance:

  • Too many small shards adds overhead
  • Too few huge shards can make each search expensive
  • Uneven shard allocation can overload one node

5) Look at node and cluster load

Search latency can rise when the cluster is under resource pressure.

Check:

GET _cat/nodes?v&h=name,cpu,heap.percent,ram.percent,load_1m,node.role
GET _nodes/stats

Look for:

  • High CPU
  • High heap usage / frequent GC
  • Disk I/O saturation
  • Thread pool rejections
  • High search queue depth

Useful areas in node stats:

  • indices.search
  • thread_pool.search
  • jvm.gc
  • fs.io_stats

If search threads are queued or rejected, the node is overloaded.


6) Check for cache misses and segment issues

Search performance depends on Lucene segment behavior and cache usage.

Possible issues:

  • Frequent indexing causing many small segments
  • Cache churn
  • Cold filesystem cache
  • Large merges happening in the background

Things to inspect:

  • Are you searching recently indexed data?
  • Is the query repeatedly executed or always unique?
  • Are segments being constantly merged?

Warm queries may be fast while first-time queries are slower due to cache cold starts.


7) Examine mappings and field types

Poor mappings can make searches slower.

Common mapping problems

  • Using text when exact matching is needed
  • Sorting/aggregating on analyzed fields
  • Missing keyword subfields
  • Fields with extremely high cardinality used in aggregations
  • Dynamic mappings creating unexpected field types

Check mappings:

GET my-index/_mapping

Good practices:

  • Use keyword for sorting, aggregations, and exact match
  • Use text for full-text search
  • Prefer doc values for aggregations/sorting

8) Review the query itself

If possible, simplify it.

Questions to ask:

  • Can any must clause be moved to filter?
  • Can you narrow the time range?
  • Do you really need all aggregations?
  • Are you sorting by _score or by a field?
  • Are you returning too many hits?
  • Are scripts used in runtime fields or script queries?

Try benchmarking a minimal version of the query and add clauses back one by one.


9) Use slow logs

Elasticsearch slow logs help identify slow queries and shards.

Configure search slow logs per index, for example:

PUT my-index/_settings
{
  "index.search.slowlog.threshold.query.warn": "5s",
  "index.search.slowlog.threshold.fetch.warn": "1s"
}

Then inspect logs for:

  • Query phase time
  • Fetch phase time
  • The exact query and shard involved

This is especially helpful when the slowness is intermittent.


10) Check the fetch phase separately

A search can be slow because of:

  • large _source
  • highlighting
  • many stored fields
  • script fields
  • rescore / post-processing

If query time is fine but fetch is slow:

  • Reduce _source
  • Avoid highlighting on large text fields unless needed
  • Return fewer fields
  • Check document size

11) Look for pagination problems

Deep pagination is a common cause of slow log searches.

Bad pattern:

"from": 50000,
"size": 50

Better:

  • search_after
  • Point-in-time (PIT) for consistent pagination
  • Time-based filtering

12) Benchmark with realistic data and concurrency

A query that is fine alone may be slow under load.

Test:

  • Query latency under production-like concurrency
  • Different time ranges
  • Different shard counts
  • Different node sizes

You may discover:

  • thread pool saturation
  • cache eviction under load
  • disk contention from concurrent ingestion

Quick checklist

If log searches are slow, check in this order:

  1. Query text and time range
  2. _profile / Search Profiler
  3. Search slow logs
  4. Shard count and distribution
  5. CPU, heap, GC, disk I/O
  6. Mapping and field types
  7. Aggregations, sorting, pagination
  8. Fetch phase / source size
  9. Concurrent load and indexing activity

If you want a fast next step

Paste:

  • your query
  • index mapping
  • shard count
  • one slow-log entry or _profile output

and I can help identify the bottleneck.

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (1 observation for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.