Some subclasses of Scorer do not honor the contract of DocsEnum.freq() [LUCENE-5315]
- Dominant language
- Java
- Stars
- 3.6k
- Forks
- 1.4k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 88
Description
The behavior of Scorer.freq() is inconsistent across its subclasses:
- For TermScorer, the freq() method behaves just as DocsEnum.freq() specifies, i.e. the method returns the "term frequency in the current document".
- For BooleanScorer2, ConjunctionScorer, DisjunctionMaxScorer, DisjunctionSumScorer, and possibly other classes, the freq() method returns the number of clauses (in BooleanQuery or DisjunctionMaxQuery) that match the current document.
This difference makes the meaning of Scorer.freq()'s return value uncertain. To add to the uncertainty, given a Query, there seems to be no way of knowing which behavior takes effect (as that is not specified in the API reference) except by reading or running the code.
This issue might be related to #5580.
---
Migrated from [LUCENE-5315](https://issues.apache.org/jira/browse/LUCENE-5315) by Kai Chan, updated Oct 30 2013
Attachments: [DisjunctionMaxQueryTest.java](https://apache.github.io/lucene-jira-archive/attachments/LUCENE-5315/DisjunctionMaxQueryTest.java), [DisjunctionMaxQueryTest.java.output](https://apache.github.io/lucene-jira-archive/attachments/LUCENE-5315/DisjunctionMaxQueryTest.java.output)
Contributor guide
Research direction
Start by reading the Scorer.freq() and DocsEnum.freq() contracts, then inspect TermScorer, BooleanScorer2, ConjunctionScorer, DisjunctionMaxScorer, and DisjunctionSumScorer. Review the attached DisjunctionMaxQueryTest.java as a test reference. Done means the freq() meaning is consistent or explicitly specified across the affected scorer implementations, with tests covering the behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- search
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100