mirror of https://github.com/apache/lucene.git
LUCENE-1837: Remove Searcher from Weight#explain - partial revert of LUCENE-1771
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@807180 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
5dd1810b0c
commit
32abcdc6de
|
@ -340,8 +340,8 @@ API Changes
|
|||
BooleanQuery's setAllowDocsOutOfOrder and getAllowDocsOutOfOrder have been
|
||||
deprecated as they are not needed anymore. BooleanQuery will now score docs
|
||||
out of order when used with a Collector that can accept docs out of order.
|
||||
Finally, Weight#explain now also takes a the top-level searcher, sub-reader
|
||||
and sub-docID.
|
||||
Finally, Weight#explain now takes a sub-reader and sub-docID, rather than
|
||||
a top level reader and docID.
|
||||
(Shai Erera, Chris Hostetter, Martin Ruckli, Mark Miller via Mike McCandless)
|
||||
|
||||
25. LUCENE-1466: Changed Tokenizer.input to be a CharStream; added
|
||||
|
|
|
@ -224,7 +224,7 @@ public class BooleanQuery extends Query {
|
|||
}
|
||||
}
|
||||
|
||||
public Explanation explain(Searcher searcher, IndexReader reader, int doc)
|
||||
public Explanation explain(IndexReader reader, int doc)
|
||||
throws IOException {
|
||||
final int minShouldMatch =
|
||||
BooleanQuery.this.getMinimumNumberShouldMatch();
|
||||
|
@ -241,7 +241,7 @@ public class BooleanQuery extends Query {
|
|||
if (w.scorer(reader, true, true) == null) {
|
||||
continue;
|
||||
}
|
||||
Explanation e = w.explain(searcher, reader, doc);
|
||||
Explanation e = w.explain(reader, doc);
|
||||
if (!c.isProhibited()) maxCoord++;
|
||||
if (e.isMatch()) {
|
||||
if (!c.isProhibited()) {
|
||||
|
|
|
@ -81,7 +81,7 @@ public class ConstantScoreQuery extends Query {
|
|||
return new ConstantScorer(similarity, reader, this);
|
||||
}
|
||||
|
||||
public Explanation explain(Searcher searcher, IndexReader reader, int doc) throws IOException {
|
||||
public Explanation explain(IndexReader reader, int doc) throws IOException {
|
||||
|
||||
ConstantScorer cs = new ConstantScorer(similarity, reader, this);
|
||||
boolean exists = cs.docIdSetIterator.advance(doc) == doc;
|
||||
|
|
|
@ -152,13 +152,13 @@ public class DisjunctionMaxQuery extends Query {
|
|||
}
|
||||
|
||||
/* Explain the score we computed for doc */
|
||||
public Explanation explain(Searcher searcher, IndexReader reader, int doc) throws IOException {
|
||||
if (disjuncts.size() == 1) return ((Weight) weights.get(0)).explain(searcher, reader,doc);
|
||||
public Explanation explain(IndexReader reader, int doc) throws IOException {
|
||||
if (disjuncts.size() == 1) return ((Weight) weights.get(0)).explain(reader,doc);
|
||||
ComplexExplanation result = new ComplexExplanation();
|
||||
float max = 0.0f, sum = 0.0f;
|
||||
result.setDescription(tieBreakerMultiplier == 0.0f ? "max of:" : "max plus " + tieBreakerMultiplier + " times others of:");
|
||||
for (Iterator iter = weights.iterator(); iter.hasNext();) {
|
||||
Explanation e = ((Weight) iter.next()).explain(searcher, reader, doc);
|
||||
Explanation e = ((Weight) iter.next()).explain(reader, doc);
|
||||
if (e.isMatch()) {
|
||||
result.setMatch(Boolean.TRUE);
|
||||
result.addDetail(e);
|
||||
|
|
|
@ -73,8 +73,8 @@ extends Query {
|
|||
weight.normalize(v);
|
||||
value = weight.getValue() * getBoost();
|
||||
}
|
||||
public Explanation explain (Searcher searcher, IndexReader ir, int i) throws IOException {
|
||||
Explanation inner = weight.explain (searcher, ir, i);
|
||||
public Explanation explain (IndexReader ir, int i) throws IOException {
|
||||
Explanation inner = weight.explain (ir, i);
|
||||
if (getBoost()!=1) {
|
||||
Explanation preBoost = inner;
|
||||
inner = new Explanation(inner.getValue()*getBoost(),"product of:");
|
||||
|
|
|
@ -313,7 +313,7 @@ public class IndexSearcher extends Searcher {
|
|||
int n = ReaderUtil.subIndex(doc, docStarts);
|
||||
int deBasedDoc = doc - docStarts[n];
|
||||
|
||||
return weight.explain(this, subReaders[n], deBasedDoc);
|
||||
return weight.explain(subReaders[n], deBasedDoc);
|
||||
}
|
||||
|
||||
private boolean fieldSortDoTrackScores;
|
||||
|
|
|
@ -129,7 +129,7 @@ public class MatchAllDocsQuery extends Query {
|
|||
normsField != null ? reader.norms(normsField) : null);
|
||||
}
|
||||
|
||||
public Explanation explain(Searcher searcher, IndexReader reader, int doc) {
|
||||
public Explanation explain(IndexReader reader, int doc) {
|
||||
// explain query weight
|
||||
Explanation queryExpl = new ComplexExplanation
|
||||
(true, getValue(), "MatchAllDocsQuery, product of:");
|
||||
|
|
|
@ -186,7 +186,7 @@ public class MultiPhraseQuery extends Query {
|
|||
slop, reader.norms(field));
|
||||
}
|
||||
|
||||
public Explanation explain(Searcher searcher, IndexReader reader, int doc)
|
||||
public Explanation explain(IndexReader reader, int doc)
|
||||
throws IOException {
|
||||
ComplexExplanation result = new ComplexExplanation();
|
||||
result.setDescription("weight("+getQuery()+" in "+doc+"), product of:");
|
||||
|
|
|
@ -158,7 +158,7 @@ public class PhraseQuery extends Query {
|
|||
|
||||
}
|
||||
|
||||
public Explanation explain(Searcher searcher, IndexReader reader, int doc)
|
||||
public Explanation explain(IndexReader reader, int doc)
|
||||
throws IOException {
|
||||
|
||||
Explanation result = new Explanation();
|
||||
|
|
|
@ -69,19 +69,14 @@ public class TermQuery extends Query {
|
|||
return new TermScorer(this, termDocs, similarity, reader.norms(term.field()));
|
||||
}
|
||||
|
||||
public Explanation explain(Searcher searcher, IndexReader reader, int doc)
|
||||
public Explanation explain(IndexReader reader, int doc)
|
||||
throws IOException {
|
||||
|
||||
ComplexExplanation result = new ComplexExplanation();
|
||||
result.setDescription("weight("+getQuery()+" in "+doc+"), product of:");
|
||||
|
||||
Explanation expl;
|
||||
if(searcher == null) {
|
||||
expl = new Explanation(idf, "idf(" + idf + ")");
|
||||
} else {
|
||||
expl = new Explanation(idf, "idf(docFreq=" + searcher.docFreq(term) +
|
||||
", maxDocs=" + searcher.maxDoc() + ")");
|
||||
}
|
||||
Explanation expl = new Explanation(idf, "idf(docFreq=" + reader.docFreq(term) +
|
||||
", maxDocs=" + reader.maxDoc() + ")");
|
||||
|
||||
// explain query weight
|
||||
Explanation queryExpl = new Explanation();
|
||||
|
|
|
@ -61,7 +61,7 @@ public abstract class Weight implements Serializable {
|
|||
* @return an Explanation for the score
|
||||
* @throws IOException
|
||||
*/
|
||||
public abstract Explanation explain(Searcher searcher, IndexReader reader, int doc) throws IOException;
|
||||
public abstract Explanation explain(IndexReader reader, int doc) throws IOException;
|
||||
|
||||
/** The query that this concerns. */
|
||||
public abstract Query getQuery();
|
||||
|
|
|
@ -341,17 +341,17 @@ public class CustomScoreQuery extends Query {
|
|||
return new CustomScorer(similarity, reader, this, subQueryScorer, valSrcScorers);
|
||||
}
|
||||
|
||||
public Explanation explain(Searcher searcher, IndexReader reader, int doc) throws IOException {
|
||||
Explanation explain = doExplain(searcher, reader, doc);
|
||||
return explain == null ? new Explanation(0.0f, "no matching docs") : doExplain(searcher, reader, doc);
|
||||
public Explanation explain(IndexReader reader, int doc) throws IOException {
|
||||
Explanation explain = doExplain(reader, doc);
|
||||
return explain == null ? new Explanation(0.0f, "no matching docs") : doExplain(reader, doc);
|
||||
}
|
||||
|
||||
private Explanation doExplain(Searcher searcher, IndexReader reader, int doc) throws IOException {
|
||||
private Explanation doExplain(IndexReader reader, int doc) throws IOException {
|
||||
Scorer[] valSrcScorers = new Scorer[valSrcWeights.length];
|
||||
for(int i = 0; i < valSrcScorers.length; i++) {
|
||||
valSrcScorers[i] = valSrcWeights[i].scorer(reader, true, false);
|
||||
}
|
||||
Explanation subQueryExpl = subQueryWeight.explain(searcher, reader, doc);
|
||||
Explanation subQueryExpl = subQueryWeight.explain(reader, doc);
|
||||
if (!subQueryExpl.isMatch()) {
|
||||
return subQueryExpl;
|
||||
}
|
||||
|
@ -451,7 +451,7 @@ public class CustomScoreQuery extends Query {
|
|||
// TODO: remove in 3.0
|
||||
/*(non-Javadoc) @see org.apache.lucene.search.Scorer#explain(int) */
|
||||
public Explanation explain(int doc) throws IOException {
|
||||
Explanation subQueryExpl = weight.subQueryWeight.explain(null, reader,doc); // nocommit: needs resolution
|
||||
Explanation subQueryExpl = weight.subQueryWeight.explain(reader,doc);
|
||||
if (!subQueryExpl.isMatch()) {
|
||||
return subQueryExpl;
|
||||
}
|
||||
|
|
|
@ -98,7 +98,7 @@ public class ValueSourceQuery extends Query {
|
|||
}
|
||||
|
||||
/*(non-Javadoc) @see org.apache.lucene.search.Weight#explain(org.apache.lucene.index.IndexReader, int) */
|
||||
public Explanation explain(Searcher searcher, IndexReader reader, int doc) throws IOException {
|
||||
public Explanation explain(IndexReader reader, int doc) throws IOException {
|
||||
return new ValueSourceScorer(similarity, reader, this).explain(doc);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ public class SpanWeight extends Weight {
|
|||
.norms(query.getField()));
|
||||
}
|
||||
|
||||
public Explanation explain(Searcher searcher, IndexReader reader, int doc)
|
||||
public Explanation explain(IndexReader reader, int doc)
|
||||
throws IOException {
|
||||
|
||||
ComplexExplanation result = new ComplexExplanation();
|
||||
|
|
|
@ -425,7 +425,7 @@ final class JustCompileSearch {
|
|||
|
||||
static final class JustCompileWeight extends Weight {
|
||||
|
||||
public Explanation explain(Searcher searcher, IndexReader reader, int doc) throws IOException {
|
||||
public Explanation explain(IndexReader reader, int doc) throws IOException {
|
||||
throw new UnsupportedOperationException(UNSUPPORTED_MSG);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue