-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Fix case sensitivity rules for wildcard queries on text fields #71751
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,8 @@ | |
| import org.apache.lucene.document.SortedSetDocValuesField; | ||
| import org.apache.lucene.index.IndexOptions; | ||
| import org.apache.lucene.index.LeafReaderContext; | ||
| import org.apache.lucene.search.MultiTermQuery; | ||
| import org.apache.lucene.search.Query; | ||
| import org.apache.lucene.util.BytesRef; | ||
| import org.elasticsearch.common.lucene.Lucene; | ||
| import org.elasticsearch.common.xcontent.XContentParser; | ||
|
|
@@ -322,6 +324,19 @@ protected BytesRef indexedValueForSearch(Object value) { | |
| return getTextSearchInfo().getSearchAnalyzer().normalize(name(), value.toString()); | ||
| } | ||
|
|
||
| /** | ||
| * Wildcard queries on keyword fields use the normalizer of the underlying field, regardless of their case sensitivity option | ||
| */ | ||
| @Override | ||
| public Query wildcardQuery( | ||
| String value, | ||
| MultiTermQuery.RewriteMethod method, | ||
| boolean caseInsensitive, | ||
| SearchExecutionContext context | ||
| ) { | ||
| return super.wildcardQuery(value, method, caseInsensitive, true, context); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe calling
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good idea, but I left the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah ok. That makes sense. |
||
| } | ||
|
|
||
| @Override | ||
| public CollapseType collapseType() { | ||
| return CollapseType.KEYWORD; | ||
|
|
@@ -332,6 +347,7 @@ public CollapseType collapseType() { | |
| public int ignoreAbove() { | ||
| return ignoreAbove; | ||
| } | ||
|
|
||
| } | ||
|
|
||
| private final boolean indexed; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a test where the search string is mixed case but set
wildCardQuery.caseInsensitive(true)