What if you could instantly know which saved searches match any new piece of data without running each search one by one?
Why Percolate queries (reverse search) in Elasticsearch? - Purpose & Use Cases
Imagine you have hundreds of saved search rules and you want to find out which rules match a new document you just received. Doing this by checking each rule one by one manually is like searching for a needle in a haystack.
Manually comparing a new document against many saved queries is slow and error-prone. It wastes time and computing power because you have to run each query separately, and it's easy to miss matches or make mistakes.
Percolate queries let you reverse the process: instead of running many queries on new data, you register your queries once, then send new documents to find which queries match instantly. This saves time and makes searching efficient and reliable.
for query in saved_queries: if query.matches(new_document): print('Match found')
POST /my_index/_percolate
{
"doc": { "field": "value" }
}It enables instant matching of new documents against many saved queries, making real-time alerting and filtering possible.
A news website wants to notify users when articles match their interests. Using percolate queries, the site quickly finds which user queries match each new article and sends alerts immediately.
Manual matching of documents to queries is slow and inefficient.
Percolate queries reverse the search process for fast matching.
This technique supports real-time notifications and filtering.