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
Made the UnifiedHighlighter's hasUnrecognizedQuery function processes FunctionQuery the same way as MatchAllDocsQuery and MatchNoDocsQuery queries for performance reasons. #13165
base: main
Are you sure you want to change the base?
Conversation
… FunctionQuery the same way as MatchAllDocsQuery and MatchNoDocsQuery queries for performance reasons.
…ery-in-unifiedhighlighter' into functionquery-as-unrecognizedquery-in-unifiedhighlighter
851b7d2
to
8801851
Compare
@@ -1130,7 +1134,16 @@ public boolean acceptField(String field) { | |||
@Override | |||
public void visitLeaf(Query query) { | |||
if (MultiTermHighlighting.canExtractAutomataFromLeafQuery(query) == false) { | |||
if (!(query instanceof MatchAllDocsQuery || query instanceof MatchNoDocsQuery)) { | |||
boolean no_effect_query = false; |
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.
This would be simpler as QUERIES_WITH_NO_HL_EFFECT.contains(query.getClass())
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.
Would you say that there is no need to capture hypothetical subclasses?
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.
MatchAllDocsQuery
is already final, but the other two aren't. Maybe this would be better done as a new protected method, isIgnorableQuery(Query q)
with a default implementation of instanceof
checks, and then if somebody has their own extension (or another query implementation that will do weird things here) they can override the method?
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 just edited my branch with your suggestion.
This PR has not had activity in the past 2 weeks, labeling it as stale. If the PR is waiting for review, notify the dev@lucene.apache.org list. Thank you for your contribution! |
@@ -1130,7 +1137,7 @@ public boolean acceptField(String field) { | |||
@Override | |||
public void visitLeaf(Query query) { | |||
if (MultiTermHighlighting.canExtractAutomataFromLeafQuery(query) == false) { | |||
if (!(query instanceof MatchAllDocsQuery || query instanceof MatchNoDocsQuery)) { | |||
if (!UnifiedHighlighter.this.isIgnorableQuery(query)) { |
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.
Can you add a test to TestUnifiedHighlighterExtensibility that checks that overrides to isIgnorableQuery
work here as well? I think it will, but to be perfectly honest I can never remember the inheritance rules around class-specific this
calls...
Thanks @vletard! This looks great, I'd just like to add one more test to ensure that inheritance works in the way we expect. |
I added a test in TestUnifiedHighlighterExtensibility, probably too simple for what you asked though.
Options 1 and 3 that I tend to prefer would require not-so-light edits, so I'd like your opinion. Thanks! |
fcf3eb6
to
908ac35
Compare
This PR has not had activity in the past 2 weeks, labeling it as stale. If the PR is waiting for review, notify the dev@lucene.apache.org list. Thank you for your contribution! |
Description
This pull request is a follow up to #12938. I took on the task of complying with @romseygeek's comment on behalf of Lexum.
I also rebased to the latest commit of
apache:main
.Let me know if any other adjustment is needed.