apache / apache/lucene

Move explain() to Scorer [LUCENE-6587]

Open
#7,645 2 comments 0 reactions 0 assignees View on GitHub
legacy-jira-priority:Major type:enhancement
Dominant language
Java
Stars
3.6k
Forks
1.4k
Avg merge
2d 11h
Merged PRs (30d)
88

Description

At the moment, the explanation API is on Weight, rather than on Scorer. This has a number of disadvantages:
- It means that Weights need to know about the scoring algorithms of their child scorers, which results in a leaky API (for example, the SloppyPhraseScorer has a package-private sloppyFreq() method which is only used by PhraseWeight.explain(), and SpanScorer has a similar public method that is again only called by explanation functions)
- It leads to lots of duplicated code - more or less every Weight.explain() method creates a Scorer, advances to the appropriate doc, and checks for a match
- It's very slow, because we create a new Scorer for every document

I'd like to try moving explain() directly to Scorer. We can keep the old slow IndexSearcher.explain() API, but in addition explanations could now be generated efficiently in a Collector.

---
Migrated from [LUCENE-6587](https://issues.apache.org/jira/browse/LUCENE-6587) by Alan Woodward (@romseygeek)
Attachments: [LUCENE-6587.patch](https://apache.github.io/lucene-jira-archive/attachments/LUCENE-6587/LUCENE-6587.patch)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.