mirror of https://github.com/apache/lucene.git
LUCENE-6526: Revert some changes that were committed by mistake.
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1683744 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c129a9080b
commit
b04702292f
|
@ -33,7 +33,6 @@ import org.apache.lucene.index.TermsEnum;
|
|||
import org.apache.lucene.search.similarities.Similarity;
|
||||
import org.apache.lucene.search.similarities.Similarity.SimScorer;
|
||||
import org.apache.lucene.util.Bits;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
import org.apache.lucene.util.ToStringUtils;
|
||||
|
||||
/**
|
||||
|
@ -42,29 +41,6 @@ import org.apache.lucene.util.ToStringUtils;
|
|||
*/
|
||||
public class TermQuery extends Query {
|
||||
|
||||
private static final Similarity.SimScorer NON_SCORING_SIM_SCORER = new Similarity.SimScorer() {
|
||||
|
||||
@Override
|
||||
public float score(int doc, float freq) {
|
||||
return 0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float computeSlopFactor(int distance) {
|
||||
return 1f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float computePayloadFactor(int doc, int start, int end, BytesRef payload) {
|
||||
return 1f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Explanation explain(int doc, Explanation freq) {
|
||||
return Explanation.match(0f, "Match on doc=" + doc);
|
||||
}
|
||||
};
|
||||
|
||||
private final Term term;
|
||||
private final TermContext perReaderTermState;
|
||||
|
||||
|
@ -130,14 +106,7 @@ public class TermQuery extends Query {
|
|||
}
|
||||
PostingsEnum docs = termsEnum.postings(acceptDocs, null, needsScores ? PostingsEnum.FREQS : PostingsEnum.NONE);
|
||||
assert docs != null;
|
||||
final Similarity.SimScorer simScorer;
|
||||
if (needsScores) {
|
||||
simScorer = similarity.simScorer(stats, context);
|
||||
} else {
|
||||
// avoids loading other scoring factors such as norms
|
||||
simScorer = NON_SCORING_SIM_SCORER;
|
||||
}
|
||||
return new TermScorer(this, docs, simScorer);
|
||||
return new TermScorer(this, docs, similarity.simScorer(stats, context));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -183,31 +183,4 @@ public class TestTermScorer extends LuceneTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
public void testDoesNotLoadNorms() throws IOException {
|
||||
Term allTerm = new Term(FIELD, "all");
|
||||
TermQuery termQuery = new TermQuery(allTerm);
|
||||
|
||||
LeafReader forbiddenNorms = new FilterLeafReader(indexReader) {
|
||||
@Override
|
||||
public NumericDocValues getNormValues(String field) throws IOException {
|
||||
fail("Norms should not be loaded");
|
||||
// unreachable
|
||||
return null;
|
||||
}
|
||||
};
|
||||
IndexSearcher indexSearcher = newSearcher(forbiddenNorms);
|
||||
|
||||
Weight weight = indexSearcher.createNormalizedWeight(termQuery, true);
|
||||
try {
|
||||
weight.scorer(forbiddenNorms.getContext(), null).nextDoc();
|
||||
fail("Should load norms");
|
||||
} catch (AssertionError e) {
|
||||
// ok
|
||||
}
|
||||
|
||||
weight = indexSearcher.createNormalizedWeight(termQuery, false);
|
||||
// should not fail this time since norms are not necessary
|
||||
weight.scorer(forbiddenNorms.getContext(), null).nextDoc();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue