0
0
Elasticsearchquery~3 mins

Why Async search for expensive queries in Elasticsearch? - Purpose & Use Cases

Choose your learning style9 modes available
The Big Idea

What if your search could run quietly in the background while you keep working?

The Scenario

Imagine you have a huge library of books and you want to find all books about a rare topic. You ask your friend to look through every shelf, but it takes a very long time. Meanwhile, you have to wait and can't do anything else.

The Problem

Doing this search manually means you wait a long time for the answer. If the search is very slow, your app or website might freeze or become unresponsive. Also, if the search fails, you lose all progress and must start over.

The Solution

Async search lets you start the search and then check back later for the results. This way, your app stays fast and responsive. You can do other things while waiting, and even handle very big searches without freezing.

Before vs After
Before
POST /_search
{
  "query": { "match": { "text": "rare topic" } }
}
After
POST /_async_search
{
  "query": { "match": { "text": "rare topic" } }
}
What It Enables

Async search makes it easy to handle slow, heavy searches without blocking your users or systems.

Real Life Example

A news website uses async search to find all articles about a breaking event across millions of records, letting readers keep browsing while the search runs.

Key Takeaways

Manual searches can block and slow down apps.

Async search runs queries in the background.

This keeps apps responsive and handles big data smoothly.