Classic search accepts a search request and finds matching documents in an index. Some use cases, however, need exactly the opposite direction: a new document arrives, and the application must figure out which of many stored search queries would match it. A typical example is a price alert, where thousands of customers have stored individual search criteria and need to be notified as soon as a new product satisfies exactly those criteria.
Elasticsearch provides the percolator query for this, which indexes stored search queries as documents in their own right and efficiently checks, for every new product, which of them match. How this works, how the price alert use case can be implemented concretely, and where the performance limits sit with very many stored queries is what this article covers.