LUCENE-1303: BoostingTermQuery's explanation marked as a Match

depending only upon the non-payload part of the score.


git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@666949 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Doron Cohen 2008-06-12 04:15:10 +00:00
parent ee9a938c79
commit d69885c9d7
3 changed files with 9 additions and 3 deletions

View File

@ -119,6 +119,11 @@ Bug fixes
12. LUCENE-1299: Fixed NPE in SpellChecker when IndexReader is not null and field is (Grant Ingersoll)
13. LUCENE-1303: Fixed BoostingTermQuery's explanation to be marked as a Match
depending only upon the non-payload score part, regardless of the effect of
the payload on the score. Prior to this, score of a query containing a BTQ
differed from its explanation. (Doron Cohen)
New features
1. LUCENE-1137: Added Token.set/getFlags() accessors for passing more information about a Token through the analysis

View File

@ -121,7 +121,7 @@ public class BoostingTermQuery extends SpanTermQuery{
public Explanation explain(final int doc) throws IOException {
Explanation result = new Explanation();
ComplexExplanation result = new ComplexExplanation();
Explanation nonPayloadExpl = super.explain(doc);
result.addDetail(nonPayloadExpl);
//QUESTION: Is there a wau to avoid this skipTo call? We need to know whether to load the payload or not
@ -140,6 +140,7 @@ public class BoostingTermQuery extends SpanTermQuery{
payloadBoost.setDescription("scorePayload(...)");
result.setValue(nonPayloadExpl.getValue() * avgPayloadScore);
result.setDescription("btq, product of:");
result.setMatch(nonPayloadExpl.getValue()==0 ? Boolean.FALSE : Boolean.TRUE); // LUCENE-1303
return result;
}
}

View File

@ -92,7 +92,7 @@ public class TestBoostingTermQuery extends LuceneTestCase {
for (int i = 0; i < 1000; i++) {
Document doc = new Document();
Field noPayloadField = new Field("noPayLoad", English.intToEnglish(i), Field.Store.YES, Field.Index.TOKENIZED);
noPayloadField.setBoost(0);
//noPayloadField.setBoost(0);
doc.add(noPayloadField);
doc.add(new Field("field", English.intToEnglish(i), Field.Store.YES, Field.Index.TOKENIZED));
doc.add(new Field("multiField", English.intToEnglish(i) + " " + English.intToEnglish(i), Field.Store.YES, Field.Index.TOKENIZED));
@ -186,7 +186,7 @@ public class TestBoostingTermQuery extends LuceneTestCase {
query.add(c2);
TopDocs hits = searcher.search(query, null, 100);
assertTrue("hits is null and it shouldn't be", hits != null);
//assertTrue("hits Size: " + hits.totalHits + " is not: " + 1, hits.totalHits == 1);
assertTrue("hits Size: " + hits.totalHits + " is not: " + 1, hits.totalHits == 1);
int[] results = new int[1];
results[0] = 0;//hits.scoreDocs[0].doc;
CheckHits.checkHitCollector(query, "noPayLoad", searcher, results);