public final class QueryAnalyzer
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static org.elasticsearch.percolator.QueryAnalyzer.Result |
analyze(Query query)
Extracts terms from the provided query.
|
public static org.elasticsearch.percolator.QueryAnalyzer.Result analyze(Query query)
When extracting the terms for the specified query, we can also determine if the percolator query is always going to match. For example if a percolator query just contains a term query or a disjunction query then when the candidate query matches with that, we know the entire percolator query always matches. This allows the percolate query to skip the expensive memory index verification step that it would otherwise have to execute (for example when a percolator query contains a phrase query or a conjunction query).
The query analyzer doesn't always extract all terms from the specified query. For example from a boolean query with no should clauses or phrase queries only the longest term are selected, since that those terms are likely to be the rarest. Boolean query's must_not clauses are always ignored.
Sometimes the query analyzer can't always extract terms from a sub query, if that happens then query analysis is stopped and an UnsupportedQueryException is thrown. So that the caller can mark this query in such a way that the PercolatorQuery always verifies if this query with the MemoryIndex.