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

Add case insensitive prefix and wildcard to 'version' field #62754

Merged
merged 4 commits into from
Sep 22, 2020

Conversation

cbuescher
Copy link
Member

This change adds support for the recently introduced case insensitivity flag for
wildcard and prefix queries. Since version field values are encoded differently we
need to adapt our own AutomatonQuery variation to add both cases if case insensitivity
is turned on.

@cbuescher cbuescher added >enhancement :Search Foundations/Mapping Index mappings, including merging and defining field types v8.0.0 v7.10.0 labels Sep 22, 2020
@elasticmachine
Copy link
Collaborator

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

@elasticmachine elasticmachine added the Team:Search Meta label for search team label Sep 22, 2020
@cbuescher
Copy link
Member Author

@markharwood would you mind taking a look since you worked on the case insensitivity option lately?

}

protected static Automaton toCaseInsensitiveChar(int codepoint, int maxDeterminizedStates) {
public static Automaton toCaseInsensitiveChar(int codepoint, int maxDeterminizedStates) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Wanted to use this, let me know if this shouldn't be that open. Another option is simpyl copying the logic over I think.

Copy link
Contributor

Choose a reason for hiding this comment

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

LGTM

@markharwood
Copy link
Contributor

I'm working on backporting the case insensitive term/prefix/wildcard query support to 7.x here
If it's OK with you I suggest that I complete that backport without adding any specialised CI support for the Version field and then you can backport this to fill in that hole?

@@ -139,7 +139,7 @@ public Query existsQuery(QueryShardContext context) {

@Override
public Query prefixQuery(String value, MultiTermQuery.RewriteMethod method, boolean caseInsensitve, QueryShardContext context) {
return wildcardQuery(value + "*", method, context);
return wildcardQuery(value + "*", method, caseInsensitve, context);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo - missing i in Insensitive.

@@ -244,7 +244,7 @@ public Query wildcardQuery(String value, MultiTermQuery.RewriteMethod method, bo
);
}

VersionFieldWildcardQuery query = new VersionFieldWildcardQuery(new Term(name(), value));
VersionFieldWildcardQuery query = new VersionFieldWildcardQuery(new Term(name(), value), caseInsensitve);
QueryParsers.setRewriteMethod(query, method);
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo

Copy link
Contributor

@markharwood markharwood left a comment

Choose a reason for hiding this comment

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

Couple of typos but otherwise LGTM

@cbuescher
Copy link
Member Author

@markharwood thanks for the review. Sure I'll wait for your backport to 7.x before backporting this PR then.

@markharwood
Copy link
Contributor

@cbuescher The 7.x backport is merged now

@cbuescher
Copy link
Member Author

@elasticmachine update branch

@cbuescher
Copy link
Member Author

@elasticmachine update branch

@cbuescher cbuescher merged commit 3ee74a4 into elastic:master Sep 22, 2020
cbuescher pushed a commit to cbuescher/elasticsearch that referenced this pull request Sep 22, 2020
…62754)

This change adds support for the recently introduced case insensitivity flag for
wildcard and prefix queries. Since version field values are encoded differently we
need to adapt our own AutomatonQuery variation to add both cases if case insensitivity
is turned on.
cbuescher pushed a commit that referenced this pull request Sep 23, 2020
…62782)

This change adds support for the recently introduced case insensitivity flag for
wildcard and prefix queries. Since version field values are encoded differently we
need to adapt our own AutomatonQuery variation to add both cases if case insensitivity
is turned on.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>enhancement :Search Foundations/Mapping Index mappings, including merging and defining field types Team:Search Meta label for search team v7.10.0 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants