Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor percolator's QueryAnalyzer to use QueryVisitors #49238

Merged
merged 7 commits into from
Nov 18, 2019

Conversation

romseygeek
Copy link
Contributor

Lucene now allows us to explore the structure of a query using QueryVisitors,
delegating the knowledge of how to recurse through and collect terms to the
query implementations themselves. The percolator currently has a home-grown
external version of this API to construct sets of matching terms that must be
present in a document in order for it to possibly match the query.

This commit removes the home-grown implementation in favour of one using
QueryVisitor. This has the added benefit of making interval queries available
for percolator pre-filtering. Due to a bug in multi-term intervals (LUCENE-9050)
it also includes a clone of some of the lucene intervals logic, that can be removed
once upstream has been fixed.

Closes #45639

@romseygeek romseygeek added >enhancement :Search Relevance/Percolator Reverse search: find queries that match a document v8.0.0 v7.6.0 labels Nov 18, 2019
@romseygeek romseygeek self-assigned this Nov 18, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search (:Search/Percolator)

Copy link
Member

@martijnvg martijnvg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

final class QueryAnalyzer {

private static final Map<Class<? extends Query>, BiFunction<Query, Version, Result>> QUERY_PROCESSORS = Map.ofEntries(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

@romseygeek romseygeek merged commit 0f6ffc2 into elastic:master Nov 18, 2019
@romseygeek romseygeek deleted the percolator-visitor branch November 18, 2019 14:53
@romseygeek
Copy link
Contributor Author

I will open a separate PR for the backport to 7x, as it's not a simple process due to the need to handle pre-6.1 indexes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>enhancement :Search Relevance/Percolator Reverse search: find queries that match a document v7.6.0 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

intervals queries fail percolator term extraction
4 participants