-
Notifications
You must be signed in to change notification settings - Fork 739
[SOLR-15030] Add score() function that returns the score of the current hit #3340
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
base: main
Are you sure you want to change the base?
Conversation
This is great, but in order to get this to work for distributed queries, we need to give |
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.
Well done!
@@ -113,4 +122,26 @@ public boolean equals(Object obj) { | |||
public int hashCode() { | |||
return 31 * classHash() + rangeFilt.hashCode(); | |||
} | |||
|
|||
private static class DelegatingCollectorWrapper extends Scorable { |
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.
the name should reflect it's Scorable-ness. Maybe DelegatingCollectorScorable
Thanks for the reviews - I'll try to put together some test cases for distributed queries, to reproduce the behavior that @HoustonPutman mentioned. |
@@ -101,4 +107,24 @@ protected void setValue(SolrDocument doc, Object val) { | |||
doc.setField(name, val); | |||
} | |||
} | |||
|
|||
private static class ScoreAndDoc extends Scorable { |
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.
There are three other ScoreAndDoc
helper classes (with identical implementation) scattered throughout the codebase. Maybe it's worth consolidating into one.
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.
One top level class makes sense!
|
||
private static final String COLLECTION = "coll1"; | ||
|
||
private static SolrClient client; |
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.
don't store a static field with a SolrClient; anyone can call cluster.getSolrClient if needed
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 love this test -- using multi-line strings and assertJSONequals! (ugh that capitalization choice is terrible though; for another PR)
// At the same time, we don't set _wantScore = true because the field | ||
// list must explicitly include 'score' field to enable scores |
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'm confused or challenge what you say in this sentence. A DocTransformer could want the score. Granted, a DocTransformer doesn't have a wantsScore
/ needsScore
so... :-/
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.
nor does a ValueSource
have needsScores
. But DoubleValuesSource
(Lucene's modern replacement over legacy VS) does.
Addressing that is perhaps for another issue/PR. Progress not perfection.
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 assume that the work-around to DocTransformer.needsScores
not existing is that the user should explicitly add score
to fl
?
Lucene standardizes on needsScores
terminology. Solr ReturnFields & ResultContext has "wants" terminology.
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.
What I thought was that for the query with fl=id,a,b,s:sum(x,y)
- even though it has a pseudo-field, that alone is not enough to conclude that the query requires scores.
Good stuff here; looking forward to it getting in. |
For consistency with how the score is referenced in |
https://issues.apache.org/jira/browse/SOLR-15030
Description
Add score() function that can be used in the following contexts:
Tests
Added tests to demonstrate the new behavior.
Checklist
Please review the following and check all that apply:
main
branch../gradlew check
.