bruno-roustant commented on a change in pull request #797: LUCENE-8921:
IndexSearcher.termStatistics requires docFreq totalTermFreq instead of
TermStates
URL: https://github.com/apache/lucene-solr/pull/797#discussion_r307301256
##########
File path: lucene/core/src/java/org/apache/lucene/search/IndexSearcher.java
##########
@@ -861,17 +861,17 @@ public String toString() {
/**
* Returns {@link TermStatistics} for a term, or {@code null} if
- * the term does not exist.
+ * the term does not exist (if docFreq == 0).
*
* This can be overridden for example, to return a term's statistics
* across a distributed collection.
* @lucene.experimental
*/
- public TermStatistics termStatistics(Term term, TermStates context) throws
IOException {
- if (context.docFreq() == 0) {
+ public TermStatistics termStatistics(Term term, int docFreq, long
totalTermFreq) throws IOException {
+ if (docFreq == 0) {
Review comment:
Previously all callers checked if the returned TermStatistics was null
before doing something. So I replaced the null check by a check if docFreq is 0.
I tried to remove the 0 check and ran TestShardSearching (which extends
ShardSearchingTestBase I modified). It failed with the exception because
docFreq was 0.
I think this check is necessary, unless some specific class is sure docFreq
will always be > 0. It this case it would not previously check null.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]