-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Set analyzer to regex query string search #3967
Set analyzer to regex query string search #3967
Conversation
Signed-off-by: yyyogev <[email protected]>
Gradle Check (Jenkins) Run Completed with:
|
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.
See below.
I am not familiar with this part of the code. Why does this work?
server/src/main/java/org/opensearch/index/search/QueryStringQueryParser.java
Outdated
Show resolved
Hide resolved
return super.getWildcardQuery(currentFieldType.name(), termStr); | ||
if (currentFieldType != null) { | ||
// return newUnmappedFieldQuery(field); | ||
setAnalyzer(forceAnalyzer == null ? queryBuilder.context.getSearchAnalyzer(currentFieldType) : forceAnalyzer); |
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.
Since we do this in multiple places maybe add a private getSearchAnalyzer(field)
method?
if/else would probably look cleaner
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.
done
Signed-off-by: yogev mets <[email protected]>
Refer to the issue associated with this PR, we discussed it all there |
Gradle Check (Jenkins) Run Completed with:
|
Signed-off-by: yogev mets <[email protected]>
… default-analyzer-regex-search
Signed-off-by: yogev mets <[email protected]>
Gradle Check (Jenkins) Run Completed with:
|
Gradle Check (Jenkins) Run Completed with:
|
Gradle Check (Jenkins) Run Completed with:
|
Signed-off-by: yogev mets <[email protected]>
Gradle Check (Jenkins) Run Completed with:
|
if (forceAnalyzer != null && (analyzeWildcard || currentFieldType.getTextSearchInfo().isTokenized())) { | ||
setAnalyzer(forceAnalyzer); | ||
return super.getWildcardQuery(currentFieldType.name(), termStr); | ||
if (currentFieldType != null) { |
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.
Hm ... did we lost if (currentFieldType == null) {
condition?
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.
I figured it will be cleaner to check if (currentFieldType != null)
now that we always set the analyzer
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.
But this is unmapped field case, we probably should return newUnmappedFieldQuery
?
Signed-off-by: yogev mets <[email protected]>
@dblock currently, when using regexp query, we only set the analyzer if it's forced (explicitly specify an analyzer in the search request). the reason is because of the wildcard queries ES introduced, but since wildcard queries are not being supported in OS, it's redundant now and only harm the regexp queries while searching for uppercase letters. The change I made removes the condition to check if the force analyzer is specified and set the analyzer regardless - either the forced or by the |
Gradle Check (Jenkins) Run Completed with:
|
Signed-off-by: yogev mets <[email protected]>
Gradle Check (Jenkins) Run Completed with:
|
Gradle Check (Jenkins) Run Completed with:
|
… default-analyzer-regex-search
Gradle Check (Jenkins) Run Completed with:
|
@yyyogev seems to be issue(s) with build pipeline:
@peterzhuamazon any hints? |
Hi sorry for the late reply guys. And we have a fix now to be reviewed. Please be patient on this as it requires a new deployment. Sorry and thanks. |
fixed now. |
Gradle Check (Jenkins) Run Completed with:
|
@dblock - just pinging as this is 2 days since the first approval. can you please check this as well? |
@reta is there anyone else who can review this one? |
Weekly ping :/ |
So sorry for the delay. @nknize any concerns here? |
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.
Nice! Clean fix. No concerns at all. Sorry for the delay here and thanks for fixing this! 🎉
Great news:) Thanks @nknize and @reta ! How would we get this in version 1.x as a bug fix? (We could create the pr's, just asking for the versions required to backport to) @yyyogev - FYI |
@AmiStrn a bit late for backport label, but basically we need to cherry-pick the commit to 2.x / 2.2 / 2.1 / 2.0 / 1.x / 1.3 manually (I think). |
Sets analyzer to regex query string search Signed-off-by: yyyogev <[email protected]> (cherry picked from commit ea4cfcc)
Sets analyzer to regex query string search Signed-off-by: yyyogev <[email protected]> (cherry picked from commit ea4cfcc)
@reta The labels work even after the PR has been merged :) |
I think 1.3 is the end of the line for 1.x releases, so backporting there will ensure the bug fix gets in to any future 1.3 release if one happens. 2.x branch will ensure the next minor release gets the fix. I think that should be sufficient? Please let me know if I'm wrong here. |
FYI: I opened #4226 until the feature is back ported since the test is consistently failing bwc CI. |
Sets analyzer to regex query string search Signed-off-by: yyyogev <[email protected]> (cherry picked from commit ea4cfcc) Signed-off-by: Daniel (dB.) Doubrovkine <[email protected]>
Sets analyzer to regex query string search Signed-off-by: yyyogev <[email protected]> (cherry picked from commit ea4cfcc) Signed-off-by: Daniel (dB.) Doubrovkine <[email protected]> Signed-off-by: Daniel (dB.) Doubrovkine <[email protected]> Co-authored-by: Yogev Mets <[email protected]>
Sets analyzer to regex query string search Signed-off-by: yogev mets <[email protected]> (cherry picked from commit ea4cfcc)
Description
Set default analyzer to query string search with regex
Issues Resolved
Resolves #3578
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.