A percolate query reverses normal search: instead of running a query against documents, it searches stored queries using a supplied document. This supports alerts when previously unavailable items become available. section 12.9.4
Create an index for stored queries, map its query field as type percolator, save a query such as name matching Python, and submit a candidate document. section 12.9.4
Finding a query that matches a newly stocked book
PUT tech_books_percolator { "mappings": { "properties": { "query": { "type": "percolator" }, "name": { "type": "text" }, "tags": { "type": "text" } } } } PUT tech_books_percolator/_doc/1 { "query": { "match": { "name": "Python" } } } GET tech_books_percolator/_search { "query": { "percolate": { "field": "query", "document": { "name": "Python in Action", "tags": ["Python", "Software Programming"] } } } } The percolate search tests the supplied book against the stored match query, identifying the user criterion that now has a result. section 12.9.4
Listing 12.32 Searching for queries in the percolator index
GET tech_books_percolator/_search
{
"query": {
"percolate": { #1
"field": "query", #2
"document": { #3
"name":"Python in Action",
"tags":["Python","Software Programming"]
}
}
}
}
Inspect the complete REST request that searches the percolator index for matching stored queries. section 12.9.4
