mirror of https://github.com/apache/lucene.git
LUCENE-8012: Explanation takes Number rather than float
This commit is contained in:
parent
ca29722b22
commit
c1030eeb74
|
@ -29,6 +29,9 @@ API Changes
|
|||
* LUCENE-8099: CustomScoreQuery, BoostedQuery and BoostingQuery have been
|
||||
removed (Alan Woodward)
|
||||
|
||||
* LUCENE-8012: Explanation now takes Number rather than float (Alan Woodward,
|
||||
Robert Muir)
|
||||
|
||||
Changes in Runtime Behavior
|
||||
|
||||
* LUCENE-7837: Indices that were created before the previous major version
|
||||
|
|
|
@ -159,7 +159,7 @@ public final class DisjunctionMaxQuery extends Query implements Iterable<Query>
|
|||
@Override
|
||||
public Explanation explain(LeafReaderContext context, int doc) throws IOException {
|
||||
boolean match = false;
|
||||
float max = 0;
|
||||
double max = 0;
|
||||
double otherSum = 0;
|
||||
List<Explanation> subs = new ArrayList<>();
|
||||
for (Weight wt : weights) {
|
||||
|
@ -167,7 +167,7 @@ public final class DisjunctionMaxQuery extends Query implements Iterable<Query>
|
|||
if (e.isMatch()) {
|
||||
match = true;
|
||||
subs.add(e);
|
||||
float score = e.getValue();
|
||||
double score = e.getValue().doubleValue();
|
||||
if (score >= max) {
|
||||
otherSum += max;
|
||||
max = score;
|
||||
|
|
|
@ -68,9 +68,9 @@ public abstract class DoubleValuesSource implements SegmentCacheable {
|
|||
* @throws IOException if an {@link IOException} occurs
|
||||
*/
|
||||
public Explanation explain(LeafReaderContext ctx, int docId, Explanation scoreExplanation) throws IOException {
|
||||
DoubleValues dv = getValues(ctx, DoubleValuesSource.constant(scoreExplanation.getValue()).getValues(ctx, null));
|
||||
DoubleValues dv = getValues(ctx, DoubleValuesSource.constant(scoreExplanation.getValue().doubleValue()).getValues(ctx, null));
|
||||
if (dv.advanceExact(docId))
|
||||
return Explanation.match((float) dv.doubleValue(), this.toString());
|
||||
return Explanation.match(dv.doubleValue(), this.toString());
|
||||
return Explanation.noMatch(this.toString());
|
||||
}
|
||||
|
||||
|
@ -305,7 +305,7 @@ public abstract class DoubleValuesSource implements SegmentCacheable {
|
|||
|
||||
@Override
|
||||
public Explanation explain(LeafReaderContext ctx, int docId, Explanation scoreExplanation) {
|
||||
return Explanation.match((float) value, "constant(" + value + ")");
|
||||
return Explanation.match(value, "constant(" + value + ")");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -405,7 +405,7 @@ public abstract class DoubleValuesSource implements SegmentCacheable {
|
|||
public Explanation explain(LeafReaderContext ctx, int docId, Explanation scoreExplanation) throws IOException {
|
||||
DoubleValues values = getValues(ctx, null);
|
||||
if (values.advanceExact(docId))
|
||||
return Explanation.match((float) values.doubleValue(), this.toString());
|
||||
return Explanation.match(values.doubleValue(), this.toString());
|
||||
else
|
||||
return Explanation.noMatch(this.toString());
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ public final class Explanation {
|
|||
* @param description how {@code value} was computed
|
||||
* @param details sub explanations that contributed to this explanation
|
||||
*/
|
||||
public static Explanation match(float value, String description, Collection<Explanation> details) {
|
||||
public static Explanation match(Number value, String description, Collection<Explanation> details) {
|
||||
return new Explanation(true, value, description, details);
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ public final class Explanation {
|
|||
* @param description how {@code value} was computed
|
||||
* @param details sub explanations that contributed to this explanation
|
||||
*/
|
||||
public static Explanation match(float value, String description, Explanation... details) {
|
||||
public static Explanation match(Number value, String description, Explanation... details) {
|
||||
return new Explanation(true, value, description, Arrays.asList(details));
|
||||
}
|
||||
|
||||
|
@ -61,14 +61,14 @@ public final class Explanation {
|
|||
}
|
||||
|
||||
private final boolean match; // whether the document matched
|
||||
private final float value; // the value of this node
|
||||
private final Number value; // the value of this node
|
||||
private final String description; // what it represents
|
||||
private final List<Explanation> details; // sub-explanations
|
||||
|
||||
/** Create a new explanation */
|
||||
private Explanation(boolean match, float value, String description, Collection<Explanation> details) {
|
||||
private Explanation(boolean match, Number value, String description, Collection<Explanation> details) {
|
||||
this.match = match;
|
||||
this.value = value;
|
||||
this.value = Objects.requireNonNull(value);
|
||||
this.description = Objects.requireNonNull(description);
|
||||
this.details = Collections.unmodifiableList(new ArrayList<>(details));
|
||||
for (Explanation detail : details) {
|
||||
|
@ -84,7 +84,7 @@ public final class Explanation {
|
|||
}
|
||||
|
||||
/** The value assigned to this explanation node. */
|
||||
public float getValue() { return value; }
|
||||
public Number getValue() { return value; }
|
||||
|
||||
/** A description of this explanation node. */
|
||||
public String getDescription() { return description; }
|
||||
|
@ -126,7 +126,7 @@ public final class Explanation {
|
|||
if (o == null || getClass() != o.getClass()) return false;
|
||||
Explanation that = (Explanation) o;
|
||||
return match == that.match &&
|
||||
Float.compare(that.value, value) == 0 &&
|
||||
Objects.equals(value, that.value) &&
|
||||
Objects.equals(description, that.description) &&
|
||||
Objects.equals(details, that.details);
|
||||
}
|
||||
|
|
|
@ -141,13 +141,13 @@ public abstract class QueryRescorer extends Rescorer {
|
|||
public Explanation explain(IndexSearcher searcher, Explanation firstPassExplanation, int docID) throws IOException {
|
||||
Explanation secondPassExplanation = searcher.explain(query, docID);
|
||||
|
||||
Float secondPassScore = secondPassExplanation.isMatch() ? secondPassExplanation.getValue() : null;
|
||||
Number secondPassScore = secondPassExplanation.isMatch() ? secondPassExplanation.getValue() : null;
|
||||
|
||||
float score;
|
||||
if (secondPassScore == null) {
|
||||
score = combine(firstPassExplanation.getValue(), false, 0.0f);
|
||||
score = combine(firstPassExplanation.getValue().floatValue(), false, 0.0f);
|
||||
} else {
|
||||
score = combine(firstPassExplanation.getValue(), true, secondPassScore.floatValue());
|
||||
score = combine(firstPassExplanation.getValue().floatValue(), true, secondPassScore.floatValue());
|
||||
}
|
||||
|
||||
Explanation first = Explanation.match(firstPassExplanation.getValue(), "first pass score", firstPassExplanation);
|
||||
|
|
|
@ -95,7 +95,7 @@ public class SortRescorer extends Rescorer {
|
|||
|
||||
@Override
|
||||
public Explanation explain(IndexSearcher searcher, Explanation firstPassExplanation, int docID) throws IOException {
|
||||
TopDocs oneHit = new TopDocs(1, new ScoreDoc[] {new ScoreDoc(docID, firstPassExplanation.getValue())});
|
||||
TopDocs oneHit = new TopDocs(1, new ScoreDoc[] {new ScoreDoc(docID, firstPassExplanation.getValue().floatValue())});
|
||||
TopDocs hits = rescore(searcher, oneHit, 1);
|
||||
assert hits.totalHits == 1;
|
||||
|
||||
|
|
|
@ -122,13 +122,14 @@ public abstract class Axiomatic extends SimilarityBase {
|
|||
protected Explanation explain(
|
||||
BasicStats stats, int doc, Explanation freq, double docLen) {
|
||||
List<Explanation> subs = new ArrayList<>();
|
||||
explain(subs, stats, doc, freq.getValue(), docLen);
|
||||
double f = freq.getValue().doubleValue();
|
||||
explain(subs, stats, doc, f, docLen);
|
||||
|
||||
double score = tf(stats, freq.getValue(), docLen)
|
||||
* ln(stats, freq.getValue(), docLen)
|
||||
* tfln(stats, freq.getValue(), docLen)
|
||||
* idf(stats, freq.getValue(), docLen)
|
||||
- gamma(stats, freq.getValue(), docLen);
|
||||
double score = tf(stats, f, docLen)
|
||||
* ln(stats, f, docLen)
|
||||
* tfln(stats, f, docLen)
|
||||
* idf(stats, f, docLen)
|
||||
- gamma(stats, f, docLen);
|
||||
|
||||
Explanation explanation = Explanation.match((float) score,
|
||||
"score(" + getClass().getSimpleName() + ", doc=" + doc + ", freq=" + freq.getValue() +"), computed from:",
|
||||
|
|
|
@ -170,7 +170,7 @@ public class BM25Similarity extends Similarity {
|
|||
for (final TermStatistics stat : termStats ) {
|
||||
Explanation idfExplain = idfExplain(collectionStats, stat);
|
||||
details.add(idfExplain);
|
||||
idf += idfExplain.getValue();
|
||||
idf += idfExplain.getValue().floatValue();
|
||||
}
|
||||
return Explanation.match((float) idf, "idf, sum of:", details);
|
||||
}
|
||||
|
@ -236,7 +236,7 @@ public class BM25Similarity extends Similarity {
|
|||
subs.addAll(stats.explain());
|
||||
Explanation tfExpl = explainTF(doc, freq);
|
||||
subs.add(tfExpl);
|
||||
return Explanation.match(stats.weight * tfExpl.getValue(),
|
||||
return Explanation.match(stats.weight * tfExpl.getValue().floatValue(),
|
||||
"score(doc="+doc+",freq="+freq.getValue()+"), product of:", subs);
|
||||
}
|
||||
|
||||
|
@ -247,7 +247,7 @@ public class BM25Similarity extends Similarity {
|
|||
if (norms == null) {
|
||||
subs.add(Explanation.match(0, "b, field omits length norms"));
|
||||
return Explanation.match(
|
||||
(float) (freq.getValue() / (freq.getValue() + (double) k1)),
|
||||
(float) (freq.getValue().floatValue() / (freq.getValue().floatValue() + (double) k1)),
|
||||
"tf, computed as freq / (freq + k1) from:", subs);
|
||||
} else {
|
||||
boolean found = norms.advanceExact(doc);
|
||||
|
@ -263,7 +263,7 @@ public class BM25Similarity extends Similarity {
|
|||
subs.add(Explanation.match(stats.avgdl, "avgdl, average length of field"));
|
||||
float normValue = k1 * ((1 - b) + b * doclen / stats.avgdl);
|
||||
return Explanation.match(
|
||||
(float) (freq.getValue() / (freq.getValue() + (double) normValue)),
|
||||
(float) (freq.getValue().floatValue() / (freq.getValue().floatValue() + (double) normValue)),
|
||||
"tf, computed as freq / (freq + k1 * (1 - b + b * dl / avgdl)) from:", subs);
|
||||
}
|
||||
}
|
||||
|
@ -294,7 +294,7 @@ public class BM25Similarity extends Similarity {
|
|||
this.avgdl = avgdl;
|
||||
this.k1 = k1;
|
||||
this.cache = cache;
|
||||
this.weight = (k1 + 1) * boost * idf.getValue();
|
||||
this.weight = (k1 + 1) * boost * idf.getValue().floatValue();
|
||||
}
|
||||
|
||||
private List<Explanation> explain() {
|
||||
|
|
|
@ -82,7 +82,7 @@ public class DFISimilarity extends SimilarityBase {
|
|||
BasicStats stats, int doc, Explanation freq, double docLen) {
|
||||
final double expected = (stats.getTotalTermFreq() + 1) * docLen /
|
||||
(stats.getNumberOfFieldTokens() + 1);
|
||||
if (freq.getValue() <= expected){
|
||||
if (freq.getValue().doubleValue() <= expected){
|
||||
return Explanation.match((float) 0, "score(" +
|
||||
getClass().getSimpleName() + ", doc=" + doc + ", freq=" +
|
||||
freq.getValue() +"), equals to 0");
|
||||
|
@ -95,14 +95,14 @@ public class DFISimilarity extends SimilarityBase {
|
|||
Explanation.match(stats.getNumberOfFieldTokens(),
|
||||
"T, total number of tokens in the field"));
|
||||
|
||||
final double measure = independence.score(freq.getValue(), expected);
|
||||
final double measure = independence.score(freq.getValue().doubleValue(), expected);
|
||||
Explanation explMeasure = Explanation.match((float) measure,
|
||||
"measure, computed as independence.score(freq, expected) from:",
|
||||
freq,
|
||||
explExpected);
|
||||
|
||||
return Explanation.match(
|
||||
(float) score(stats, freq.getValue(), docLen),
|
||||
(float) score(stats, freq.getValue().doubleValue(), docLen),
|
||||
"score(" + getClass().getSimpleName() + ", doc=" + doc + ", freq=" +
|
||||
freq.getValue() +"), computed as boost * log2(measure + 1) from:",
|
||||
Explanation.match( (float)stats.getBoost(), "boost, query boost"),
|
||||
|
|
|
@ -138,10 +138,10 @@ public class DFRSimilarity extends SimilarityBase {
|
|||
protected Explanation explain(
|
||||
BasicStats stats, int doc, Explanation freq, double docLen) {
|
||||
List<Explanation> subs = new ArrayList<>();
|
||||
explain(subs, stats, doc, freq.getValue(), docLen);
|
||||
explain(subs, stats, doc, freq.getValue().doubleValue(), docLen);
|
||||
|
||||
return Explanation.match(
|
||||
(float) score(stats, freq.getValue(), docLen),
|
||||
(float) score(stats, freq.getValue().doubleValue(), docLen),
|
||||
"score(" + getClass().getSimpleName() + ", doc=" + doc + ", freq=" +
|
||||
freq.getValue() +"), computed as boost * " +
|
||||
"basicModel.score(stats, tfn) * afterEffect.score(stats, tfn) from:",
|
||||
|
|
|
@ -120,17 +120,17 @@ public class IBSimilarity extends SimilarityBase {
|
|||
Explanation lambdaExpl = lambda.explain(stats);
|
||||
subs.add(normExpl);
|
||||
subs.add(lambdaExpl);
|
||||
subs.add(distribution.explain(stats, normExpl.getValue(), lambdaExpl.getValue()));
|
||||
subs.add(distribution.explain(stats, normExpl.getValue().floatValue(), lambdaExpl.getValue().floatValue()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Explanation explain(
|
||||
BasicStats stats, int doc, Explanation freq, double docLen) {
|
||||
List<Explanation> subs = new ArrayList<>();
|
||||
explain(subs, stats, doc, freq.getValue(), docLen);
|
||||
explain(subs, stats, doc, freq.getValue().doubleValue(), docLen);
|
||||
|
||||
return Explanation.match(
|
||||
(float) score(stats, freq.getValue(), docLen),
|
||||
(float) score(stats, freq.getValue().doubleValue(), docLen),
|
||||
"score(" + getClass().getSimpleName() + ", doc=" + doc + ", freq=" +
|
||||
freq.getValue() +"), computed as boost * " +
|
||||
"distribution.score(stats, normalization.tfn(stats, freq," +
|
||||
|
|
|
@ -114,10 +114,10 @@ public class LMDirichletSimilarity extends LMSimilarity {
|
|||
protected Explanation explain(
|
||||
BasicStats stats, int doc, Explanation freq, double docLen) {
|
||||
List<Explanation> subs = new ArrayList<>();
|
||||
explain(subs, stats, doc, freq.getValue(), docLen);
|
||||
explain(subs, stats, doc, freq.getValue().doubleValue(), docLen);
|
||||
|
||||
return Explanation.match(
|
||||
(float) score(stats, freq.getValue(), docLen),
|
||||
(float) score(stats, freq.getValue().doubleValue(), docLen),
|
||||
"score(" + getClass().getSimpleName() + ", doc=" + doc + ", freq=" +
|
||||
freq.getValue() +"), computed as boost * " +
|
||||
"(term weight + document norm) from:",
|
||||
|
|
|
@ -95,10 +95,10 @@ public class LMJelinekMercerSimilarity extends LMSimilarity {
|
|||
protected Explanation explain(
|
||||
BasicStats stats, int doc, Explanation freq, double docLen) {
|
||||
List<Explanation> subs = new ArrayList<>();
|
||||
explain(subs, stats, doc, freq.getValue(), docLen);
|
||||
explain(subs, stats, doc, freq.getValue().doubleValue(), docLen);
|
||||
|
||||
return Explanation.match(
|
||||
(float) score(stats, freq.getValue(), docLen),
|
||||
(float) score(stats, freq.getValue().doubleValue(), docLen),
|
||||
"score(" + getClass().getSimpleName() + ", doc=" + doc + ", freq=" +
|
||||
freq.getValue() +"), computed as boost * " +
|
||||
"log(1 + ((1 - lambda) * freq / dl) /(lambda * P)) from:",
|
||||
|
|
|
@ -97,7 +97,7 @@ public class MultiSimilarity extends Similarity {
|
|||
for (SimScorer subScorer : subScorers) {
|
||||
subs.add(subScorer.explain(doc, freq));
|
||||
}
|
||||
return Explanation.match(score(doc, freq.getValue()), "sum of:", subs);
|
||||
return Explanation.match(score(doc, freq.getValue().floatValue()), "sum of:", subs);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -173,7 +173,7 @@ public abstract class Similarity {
|
|||
*/
|
||||
public Explanation explain(int doc, Explanation freq) throws IOException {
|
||||
return Explanation.match(
|
||||
score(doc, freq.getValue()),
|
||||
score(doc, freq.getValue().floatValue()),
|
||||
"score(doc=" + doc + ",freq=" + freq.getValue() +"), with freq of:",
|
||||
Collections.singleton(freq));
|
||||
}
|
||||
|
|
|
@ -162,10 +162,10 @@ public abstract class SimilarityBase extends Similarity {
|
|||
protected Explanation explain(
|
||||
BasicStats stats, int doc, Explanation freq, double docLen) {
|
||||
List<Explanation> subs = new ArrayList<>();
|
||||
explain(subs, stats, doc, freq.getValue(), docLen);
|
||||
explain(subs, stats, doc, freq.getValue().floatValue(), docLen);
|
||||
|
||||
return Explanation.match(
|
||||
(float) score(stats, freq.getValue(), docLen),
|
||||
(float) score(stats, freq.getValue().floatValue(), docLen),
|
||||
"score(" + getClass().getSimpleName() + ", doc=" + doc + ", freq=" + freq.getValue() +"), computed from:",
|
||||
subs);
|
||||
}
|
||||
|
|
|
@ -472,7 +472,7 @@ public abstract class TFIDFSimilarity extends Similarity {
|
|||
for (final TermStatistics stat : termStats ) {
|
||||
Explanation idfExplain = idfExplain(collectionStats, stat);
|
||||
subs.add(idfExplain);
|
||||
idf += idfExplain.getValue();
|
||||
idf += idfExplain.getValue().floatValue();
|
||||
}
|
||||
return Explanation.match((float) idf, "idf(), sum of:", subs);
|
||||
}
|
||||
|
@ -595,7 +595,7 @@ public abstract class TFIDFSimilarity extends Similarity {
|
|||
this.field = field;
|
||||
this.idf = idf;
|
||||
this.boost = boost;
|
||||
this.queryWeight = boost * idf.getValue();
|
||||
this.queryWeight = boost * idf.getValue().floatValue();
|
||||
this.normTable = normTable;
|
||||
}
|
||||
}
|
||||
|
@ -606,7 +606,7 @@ public abstract class TFIDFSimilarity extends Similarity {
|
|||
subs.add(Explanation.match(stats.boost, "boost"));
|
||||
}
|
||||
subs.add(stats.idf);
|
||||
Explanation tf = Explanation.match(tf(freq.getValue()), "tf(freq="+freq.getValue()+"), with freq of:", freq);
|
||||
Explanation tf = Explanation.match(tf(freq.getValue().floatValue()), "tf(freq="+freq.getValue()+"), with freq of:", freq);
|
||||
subs.add(tf);
|
||||
|
||||
float norm;
|
||||
|
@ -624,7 +624,7 @@ public abstract class TFIDFSimilarity extends Similarity {
|
|||
subs.add(fieldNorm);
|
||||
|
||||
return Explanation.match(
|
||||
stats.queryWeight * tf.getValue() * norm,
|
||||
stats.queryWeight * tf.getValue().floatValue() * norm,
|
||||
"score(doc="+doc+",freq="+freq.getValue()+"), product of:",
|
||||
subs);
|
||||
}
|
||||
|
|
|
@ -523,7 +523,7 @@ public class TestBooleanQuery extends LuceneTestCase {
|
|||
@Override
|
||||
public void collect(int doc) throws IOException {
|
||||
final float actualScore = scorer.score();
|
||||
final float expectedScore = searcher.explain(bq2, docBase + doc).getValue();
|
||||
final float expectedScore = searcher.explain(bq2, docBase + doc).getValue().floatValue();
|
||||
assertEquals(expectedScore, actualScore, 10e-5);
|
||||
matched.set(true);
|
||||
}
|
||||
|
|
|
@ -183,7 +183,7 @@ public class TestDocValuesScoring extends LuceneTestCase {
|
|||
Explanation boostExplanation = Explanation.match(getValueForDoc(doc), "indexDocValue(" + boostField + ")");
|
||||
Explanation simExplanation = sub.explain(doc, freq);
|
||||
return Explanation.match(
|
||||
boostExplanation.getValue() * simExplanation.getValue(),
|
||||
boostExplanation.getValue().doubleValue() * simExplanation.getValue().doubleValue(),
|
||||
"product of:", boostExplanation, simExplanation);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -257,7 +257,7 @@ public class TestQueryRescorer extends LuceneTestCase {
|
|||
assertTrue(s.contains("combined first and second pass score"));
|
||||
assertTrue(s.contains("first pass score"));
|
||||
assertTrue(s.contains("= second pass score"));
|
||||
assertEquals(hits2.scoreDocs[0].score, explain.getValue(), 0.0f);
|
||||
assertEquals(hits2.scoreDocs[0].score, explain.getValue().doubleValue(), 0.0f);
|
||||
|
||||
docID = hits2.scoreDocs[1].doc;
|
||||
explain = rescorer.explain(searcher,
|
||||
|
@ -269,7 +269,7 @@ public class TestQueryRescorer extends LuceneTestCase {
|
|||
assertTrue(s.contains("first pass score"));
|
||||
assertTrue(s.contains("no second pass score"));
|
||||
assertFalse(s.contains("= second pass score"));
|
||||
assertEquals(hits2.scoreDocs[1].score, explain.getValue(), 0.0f);
|
||||
assertEquals(hits2.scoreDocs[1].score, explain.getValue().doubleValue(), 0.0f);
|
||||
|
||||
r.close();
|
||||
dir.close();
|
||||
|
|
|
@ -208,7 +208,7 @@ public class TestSimilarity2 extends LuceneTestCase {
|
|||
is.setSimilarity(sims.get(i));
|
||||
Explanation expected = scores.get(i);
|
||||
Explanation actual = is.explain(query, 0);
|
||||
assertEquals(sims.get(i).toString() + ": actual=" + actual + ",expected=" + expected, expected.getValue(), actual.getValue(), 0F);
|
||||
assertEquals(sims.get(i).toString() + ": actual=" + actual + ",expected=" + expected, expected.getValue(), actual.getValue());
|
||||
}
|
||||
|
||||
iw.close();
|
||||
|
|
|
@ -213,7 +213,7 @@ public class TestSimilarityBase extends LuceneTestCase {
|
|||
toTermStats(stats));
|
||||
float score = (float)sim.score(realStats, freq, docLen);
|
||||
float explScore = sim.explain(
|
||||
realStats, 1, Explanation.match(freq, "freq"), docLen).getValue();
|
||||
realStats, 1, Explanation.match(freq, "freq"), docLen).getValue().floatValue();
|
||||
assertFalse("Score infinite: " + sim.toString(), Float.isInfinite(score));
|
||||
assertFalse("Score NaN: " + sim.toString(), Float.isNaN(score));
|
||||
assertTrue("Score negative: " + sim.toString(), score >= 0);
|
||||
|
|
|
@ -148,8 +148,8 @@ public class TestBasics extends LuceneTestCase {
|
|||
checkHits(query, new int[]
|
||||
{77, 177, 277, 377, 477, 577, 677, 777, 877, 977, 1077, 1177, 1277, 1377, 1477, 1577, 1677, 1777, 1877, 1977});
|
||||
|
||||
assertTrue(searcher.explain(query, 77).getValue() > 0.0f);
|
||||
assertTrue(searcher.explain(query, 977).getValue() > 0.0f);
|
||||
assertTrue(searcher.explain(query, 77).getValue().doubleValue() > 0.0f);
|
||||
assertTrue(searcher.explain(query, 977).getValue().doubleValue() > 0.0f);
|
||||
}
|
||||
|
||||
public void testSpanTermQuery() throws Exception {
|
||||
|
@ -193,8 +193,8 @@ public class TestBasics extends LuceneTestCase {
|
|||
checkHits(query, new int[]
|
||||
{801, 821, 831, 851, 861, 871, 881, 891, 1801, 1821, 1831, 1851, 1861, 1871, 1881, 1891});
|
||||
|
||||
assertTrue(searcher.explain(query, 801).getValue() > 0.0f);
|
||||
assertTrue(searcher.explain(query, 891).getValue() > 0.0f);
|
||||
assertTrue(searcher.explain(query, 801).getValue().doubleValue() > 0.0f);
|
||||
assertTrue(searcher.explain(query, 891).getValue().doubleValue() > 0.0f);
|
||||
}
|
||||
|
||||
public void testSpanNotNoOverflowOnLargeSpans() throws Exception {
|
||||
|
@ -214,8 +214,8 @@ public class TestBasics extends LuceneTestCase {
|
|||
{801, 821, 831, 851, 861, 871, 881, 891,
|
||||
1801, 1821, 1831, 1851, 1861, 1871, 1881, 1891});
|
||||
|
||||
assertTrue(searcher.explain(query, 801).getValue() > 0.0f);
|
||||
assertTrue(searcher.explain(query, 891).getValue() > 0.0f);
|
||||
assertTrue(searcher.explain(query, 801).getValue().doubleValue() > 0.0f);
|
||||
assertTrue(searcher.explain(query, 891).getValue().doubleValue() > 0.0f);
|
||||
}
|
||||
|
||||
public void testSpanWithMultipleNotMany() throws Exception {
|
||||
|
@ -226,8 +226,8 @@ public class TestBasics extends LuceneTestCase {
|
|||
checkHits(query, new int[]
|
||||
{801, 821, 831, 851, 871, 891, 1801, 1821, 1831, 1851, 1871, 1891});
|
||||
|
||||
assertTrue(searcher.explain(query, 801).getValue() > 0.0f);
|
||||
assertTrue(searcher.explain(query, 891).getValue() > 0.0f);
|
||||
assertTrue(searcher.explain(query, 801).getValue().doubleValue() > 0.0f);
|
||||
assertTrue(searcher.explain(query, 891).getValue().doubleValue() > 0.0f);
|
||||
}
|
||||
|
||||
public void testNpeInSpanNearWithSpanNot() throws Exception {
|
||||
|
@ -239,8 +239,8 @@ public class TestBasics extends LuceneTestCase {
|
|||
{801, 821, 831, 851, 861, 871, 881, 891,
|
||||
1801, 1821, 1831, 1851, 1861, 1871, 1881, 1891});
|
||||
|
||||
assertTrue(searcher.explain(query, 801).getValue() > 0.0f);
|
||||
assertTrue(searcher.explain(query, 891).getValue() > 0.0f);
|
||||
assertTrue(searcher.explain(query, 801).getValue().doubleValue() > 0.0f);
|
||||
assertTrue(searcher.explain(query, 891).getValue().doubleValue() > 0.0f);
|
||||
}
|
||||
|
||||
public void testNpeInSpanNearInSpanFirstInSpanNot() throws Exception {
|
||||
|
@ -267,8 +267,8 @@ public class TestBasics extends LuceneTestCase {
|
|||
{840, 842, 843, 844, 845, 846, 847, 848, 849,
|
||||
1840, 1842, 1843, 1844, 1845, 1846, 1847, 1848, 1849});
|
||||
|
||||
assertTrue(searcher.explain(query, 840).getValue() > 0.0f);
|
||||
assertTrue(searcher.explain(query, 1842).getValue() > 0.0f);
|
||||
assertTrue(searcher.explain(query, 840).getValue().doubleValue() > 0.0f);
|
||||
assertTrue(searcher.explain(query, 1842).getValue().doubleValue() > 0.0f);
|
||||
}
|
||||
|
||||
public void testSpanNotWindowTwoBefore() throws Exception {
|
||||
|
@ -278,8 +278,8 @@ public class TestBasics extends LuceneTestCase {
|
|||
checkHits(query, new int[]
|
||||
{840, 841, 842, 843, 844, 845, 846, 847, 848, 849});
|
||||
|
||||
assertTrue(searcher.explain(query, 840).getValue() > 0.0f);
|
||||
assertTrue(searcher.explain(query, 849).getValue() > 0.0f);
|
||||
assertTrue(searcher.explain(query, 840).getValue().doubleValue() > 0.0f);
|
||||
assertTrue(searcher.explain(query, 849).getValue().doubleValue() > 0.0f);
|
||||
}
|
||||
|
||||
public void testSpanNotWindowNegPost() throws Exception {
|
||||
|
@ -296,8 +296,8 @@ public class TestBasics extends LuceneTestCase {
|
|||
{801, 821, 831, 841, 851, 861, 871, 881, 891,
|
||||
1801, 1821, 1831, 1841, 1851, 1861, 1871, 1881, 1891});
|
||||
|
||||
assertTrue(searcher.explain(query, 801).getValue() > 0.0f);
|
||||
assertTrue(searcher.explain(query, 891).getValue() > 0.0f);
|
||||
assertTrue(searcher.explain(query, 801).getValue().doubleValue() > 0.0f);
|
||||
assertTrue(searcher.explain(query, 891).getValue().doubleValue() > 0.0f);
|
||||
}
|
||||
|
||||
public void testSpanNotWindowNegPre() throws Exception {
|
||||
|
@ -314,8 +314,8 @@ public class TestBasics extends LuceneTestCase {
|
|||
{801, 821, 831, 841, 851, 861, 871, 881, 891,
|
||||
1801, 1821, 1831, 1841, 1851, 1861, 1871, 1881, 1891});
|
||||
|
||||
assertTrue(searcher.explain(query, 801).getValue() > 0.0f);
|
||||
assertTrue(searcher.explain(query, 891).getValue() > 0.0f);
|
||||
assertTrue(searcher.explain(query, 801).getValue().doubleValue() > 0.0f);
|
||||
assertTrue(searcher.explain(query, 891).getValue().doubleValue() > 0.0f);
|
||||
}
|
||||
|
||||
public void testSpanNotWindowDoubleExcludesBefore() throws Exception {
|
||||
|
@ -327,8 +327,8 @@ public class TestBasics extends LuceneTestCase {
|
|||
checkHits(query, new int[]
|
||||
{42, 242, 342, 442, 542, 642, 742, 842, 942});
|
||||
|
||||
assertTrue(searcher.explain(query, 242).getValue() > 0.0f);
|
||||
assertTrue(searcher.explain(query, 942).getValue() > 0.0f);
|
||||
assertTrue(searcher.explain(query, 242).getValue().doubleValue() > 0.0f);
|
||||
assertTrue(searcher.explain(query, 942).getValue().doubleValue() > 0.0f);
|
||||
}
|
||||
|
||||
public void testSpanFirst() throws Exception {
|
||||
|
@ -344,8 +344,8 @@ public class TestBasics extends LuceneTestCase {
|
|||
584, 585, 586, 587, 588, 589, 590, 591, 592, 593, 594, 595, 596, 597,
|
||||
598, 599});
|
||||
|
||||
assertTrue(searcher.explain(query, 5).getValue() > 0.0f);
|
||||
assertTrue(searcher.explain(query, 599).getValue() > 0.0f);
|
||||
assertTrue(searcher.explain(query, 5).getValue().doubleValue() > 0.0f);
|
||||
assertTrue(searcher.explain(query, 599).getValue().doubleValue() > 0.0f);
|
||||
|
||||
}
|
||||
|
||||
|
@ -355,8 +355,8 @@ public class TestBasics extends LuceneTestCase {
|
|||
|
||||
checkHits(query, new int[]
|
||||
{25,35, 45, 55, 65, 75, 85, 95});
|
||||
assertTrue(searcher.explain(query, 25).getValue() > 0.0f);
|
||||
assertTrue(searcher.explain(query, 95).getValue() > 0.0f);
|
||||
assertTrue(searcher.explain(query, 25).getValue().doubleValue() > 0.0f);
|
||||
assertTrue(searcher.explain(query, 95).getValue().doubleValue() > 0.0f);
|
||||
|
||||
query = spanPositionRangeQuery(term1, 0, 1);
|
||||
checkHits(query, new int[]
|
||||
|
@ -384,8 +384,8 @@ public class TestBasics extends LuceneTestCase {
|
|||
747, 833, 847, 933, 947, 1033, 1047, 1133, 1147, 1233, 1247, 1333,
|
||||
1347, 1433, 1447, 1533, 1547, 1633, 1647, 1733, 1747, 1833, 1847, 1933, 1947});
|
||||
|
||||
assertTrue(searcher.explain(query, 33).getValue() > 0.0f);
|
||||
assertTrue(searcher.explain(query, 947).getValue() > 0.0f);
|
||||
assertTrue(searcher.explain(query, 33).getValue().doubleValue() > 0.0f);
|
||||
assertTrue(searcher.explain(query, 947).getValue().doubleValue() > 0.0f);
|
||||
}
|
||||
|
||||
public void testSpanExactNested() throws Exception {
|
||||
|
@ -395,7 +395,7 @@ public class TestBasics extends LuceneTestCase {
|
|||
|
||||
checkHits(query, new int[] {333, 1333});
|
||||
|
||||
assertTrue(searcher.explain(query, 333).getValue() > 0.0f);
|
||||
assertTrue(searcher.explain(query, 333).getValue().doubleValue() > 0.0f);
|
||||
}
|
||||
|
||||
public void testSpanNearOr() throws Exception {
|
||||
|
|
|
@ -255,7 +255,7 @@ public class TestNearSpansOrdered extends LuceneTestCase {
|
|||
Explanation e = searcher.explain(q, 1);
|
||||
assertTrue("Scorer explanation value for doc#1 isn't positive: "
|
||||
+ e.toString(),
|
||||
0.0f <= e.getValue());
|
||||
0.0f <= e.getValue().doubleValue());
|
||||
}
|
||||
|
||||
public void testGaps() throws Exception {
|
||||
|
|
|
@ -158,7 +158,7 @@ final class ExpressionValueSource extends DoubleValuesSource {
|
|||
@Override
|
||||
public Explanation explain(LeafReaderContext ctx, int docId, Explanation scoreExplanation) throws IOException {
|
||||
Explanation[] explanations = new Explanation[variables.length];
|
||||
DoubleValues dv = getValues(ctx, DoubleValuesSource.constant(scoreExplanation.getValue()).getValues(ctx, null));
|
||||
DoubleValues dv = getValues(ctx, DoubleValuesSource.constant(scoreExplanation.getValue().doubleValue()).getValues(ctx, null));
|
||||
if (dv.advanceExact(docId) == false) {
|
||||
return Explanation.noMatch(expression.sourceText);
|
||||
}
|
||||
|
@ -166,7 +166,7 @@ final class ExpressionValueSource extends DoubleValuesSource {
|
|||
for (DoubleValuesSource var : variables) {
|
||||
explanations[i++] = var.explain(ctx, docId, scoreExplanation);
|
||||
}
|
||||
return Explanation.match((float) dv.doubleValue(), expression.sourceText + ", computed from:", explanations);
|
||||
return Explanation.match(dv.doubleValue(), expression.sourceText + ", computed from:", explanations);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -347,7 +347,7 @@ public class ToParentBlockJoinQuery extends Query {
|
|||
Explanation child = childWeight.explain(context, childDoc - context.docBase);
|
||||
if (child.isMatch()) {
|
||||
matches++;
|
||||
if (bestChild == null || child.getValue() > bestChild.getValue()) {
|
||||
if (bestChild == null || child.getValue().floatValue() > bestChild.getValue().floatValue()) {
|
||||
bestChild = child;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -833,7 +833,7 @@ public class TestBlockJoin extends LuceneTestCase {
|
|||
int childId = Integer.parseInt(document.get("childID"));
|
||||
//System.out.println(" hit docID=" + hit.doc + " childId=" + childId + " parentId=" + document.get("parentID"));
|
||||
assertTrue(explanation.isMatch());
|
||||
assertEquals(hit.score, explanation.getValue(), 0.0f);
|
||||
assertEquals(hit.score, explanation.getValue().doubleValue(), 0.0f);
|
||||
Matcher m = Pattern.compile("Score based on ([0-9]+) child docs in range from ([0-9]+) to ([0-9]+), best match:").matcher(explanation.getDescription());
|
||||
assertTrue("Block Join description not matches", m.matches());
|
||||
assertTrue("Matched children not positive", Integer.parseInt(m.group(1)) > 0);
|
||||
|
@ -1373,7 +1373,7 @@ public class TestBlockJoin extends LuceneTestCase {
|
|||
TopDocs hits = s.search(toChildQuery, 10);
|
||||
assertEquals(hits.scoreDocs.length, 2);
|
||||
for (int i = 0; i < hits.scoreDocs.length; i++) {
|
||||
assertEquals(hits.scoreDocs[i].score, s.explain(toChildQuery, hits.scoreDocs[i].doc).getValue(), 0.01);
|
||||
assertEquals(hits.scoreDocs[i].score, s.explain(toChildQuery, hits.scoreDocs[i].doc).getValue().doubleValue(), 0f);
|
||||
}
|
||||
|
||||
r.close();
|
||||
|
|
|
@ -1293,7 +1293,7 @@ public class TestJoinUtil extends LuceneTestCase {
|
|||
assertEquals(expectedTopDocs.scoreDocs[i].doc, actualTopDocs.scoreDocs[i].doc);
|
||||
assertEquals(expectedTopDocs.scoreDocs[i].score, actualTopDocs.scoreDocs[i].score, 0.0f);
|
||||
Explanation explanation = indexSearcher.explain(joinQuery, expectedTopDocs.scoreDocs[i].doc);
|
||||
assertEquals(expectedTopDocs.scoreDocs[i].score, explanation.getValue(), 0.0f);
|
||||
assertEquals(expectedTopDocs.scoreDocs[i].score, explanation.getValue().doubleValue(), 0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ public class SweetSpotSimilarityTest extends LuceneTestCase {
|
|||
dir.close();
|
||||
Explanation norm = findExplanation(expl, "fieldNorm");
|
||||
assertNotNull(norm);
|
||||
return norm.getValue();
|
||||
return norm.getValue().floatValue();
|
||||
}
|
||||
|
||||
private static Explanation findExplanation(Explanation expl, String text) {
|
||||
|
|
|
@ -131,13 +131,13 @@ public class FunctionQuery extends Query {
|
|||
|
||||
public Explanation explain(int doc) throws IOException {
|
||||
Explanation expl = vals.explain(doc);
|
||||
if (expl.getValue() < 0) {
|
||||
if (expl.getValue().floatValue() < 0) {
|
||||
expl = Explanation.match(0, "truncated score, max of:", Explanation.match(0f, "minimum score"), expl);
|
||||
} else if (Float.isNaN(expl.getValue())) {
|
||||
} else if (Float.isNaN(expl.getValue().floatValue())) {
|
||||
expl = Explanation.match(0, "score, computed as (score == NaN ? 0 : score) since NaN is an illegal score from:", expl);
|
||||
}
|
||||
|
||||
return Explanation.match(boost * expl.getValue(), "FunctionQuery(" + func + "), product of:",
|
||||
return Explanation.match(boost * expl.getValue().floatValue(), "FunctionQuery(" + func + "), product of:",
|
||||
vals.explain(doc),
|
||||
Explanation.match(weight.boost, "boost"));
|
||||
}
|
||||
|
|
|
@ -249,7 +249,7 @@ public abstract class ValueSource {
|
|||
public Explanation explain(LeafReaderContext ctx, int docId, Explanation scoreExplanation) throws IOException {
|
||||
Map context = new HashMap<>();
|
||||
FakeScorer scorer = new FakeScorer();
|
||||
scorer.score = scoreExplanation.getValue();
|
||||
scorer.score = scoreExplanation.getValue().floatValue();
|
||||
context.put("scorer", scorer);
|
||||
context.put("searcher", searcher);
|
||||
FunctionValues fv = in.getValues(context, ctx);
|
||||
|
|
|
@ -244,9 +244,9 @@ public class PayloadScoreQuery extends SpanQuery {
|
|||
|
||||
protected Explanation getPayloadExplanation() {
|
||||
Explanation expl = function.explain(docID(), getField(), spans.payloadsSeen, spans.payloadScore);
|
||||
if (expl.getValue() < 0) {
|
||||
if (expl.getValue().floatValue() < 0) {
|
||||
expl = Explanation.match(0, "truncated score, max of:", Explanation.match(0f, "minimum score"), expl);
|
||||
} else if (Float.isNaN(expl.getValue())) {
|
||||
} else if (Float.isNaN(expl.getValue().floatValue())) {
|
||||
expl = Explanation.match(0, "payload score, computed as (score == NaN ? 0 : score) since NaN is an illegal score from:", expl);
|
||||
}
|
||||
return expl;
|
||||
|
|
|
@ -67,7 +67,7 @@ public class TestFunctionScoreExplanations extends BaseExplanationTestCase {
|
|||
Explanation e1 = searcher.explain(q, 0);
|
||||
Explanation e = searcher.explain(fsq, 0);
|
||||
|
||||
assertEquals(e.getValue(), e1.getValue(), 0.00001);
|
||||
assertEquals(e.getValue(), e1.getValue());
|
||||
assertEquals(e.getDetails()[0], e1);
|
||||
|
||||
}
|
||||
|
@ -86,19 +86,19 @@ public class TestFunctionScoreExplanations extends BaseExplanationTestCase {
|
|||
expl = searcher.explain(query, 0);
|
||||
assertEquals(2, expl.getDetails().length);
|
||||
// function
|
||||
assertEquals(5f, expl.getDetails()[1].getValue(), 0f);
|
||||
assertEquals(5f, expl.getDetails()[1].getValue().doubleValue(), 0f);
|
||||
// boost
|
||||
assertEquals("boost", expl.getDetails()[0].getDescription());
|
||||
assertEquals(2f, expl.getDetails()[0].getValue(), 0f);
|
||||
assertEquals(2f, expl.getDetails()[0].getValue().doubleValue(), 0f);
|
||||
|
||||
searcher.setSimilarity(new ClassicSimilarity()); // in order to have a queryNorm != 1
|
||||
expl = searcher.explain(query, 0);
|
||||
assertEquals(2, expl.getDetails().length);
|
||||
// function
|
||||
assertEquals(5f, expl.getDetails()[1].getValue(), 0f);
|
||||
assertEquals(5f, expl.getDetails()[1].getValue().doubleValue(), 0f);
|
||||
// boost
|
||||
assertEquals("boost", expl.getDetails()[0].getDescription());
|
||||
assertEquals(2f, expl.getDetails()[0].getValue(), 0f);
|
||||
assertEquals(2f, expl.getDetails()[0].getValue().doubleValue(), 0f);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -161,7 +161,7 @@ public class TestFunctionScoreQuery extends FunctionTestSetup {
|
|||
Query q = new FunctionScoreQuery(new MatchAllDocsQuery(), DoubleValuesSource.fromLongField("foo"));
|
||||
QueryUtils.check(random(), q, searcher);
|
||||
Explanation expl = searcher.explain(q, 0);
|
||||
assertEquals(0, expl.getValue(), 0f);
|
||||
assertEquals(0, expl.getValue().doubleValue(), 0f);
|
||||
assertTrue(expl.toString(), expl.getDetails()[0].getDescription().contains("truncated score"));
|
||||
reader.close();
|
||||
dir.close();
|
||||
|
@ -179,7 +179,7 @@ public class TestFunctionScoreQuery extends FunctionTestSetup {
|
|||
Query q = new FunctionScoreQuery(new MatchAllDocsQuery(), DoubleValuesSource.fromDoubleField("foo"));
|
||||
QueryUtils.check(random(), q, searcher);
|
||||
Explanation expl = searcher.explain(q, 0);
|
||||
assertEquals(0, expl.getValue(), 0f);
|
||||
assertEquals(0, expl.getValue().doubleValue(), 0f);
|
||||
assertTrue(expl.toString(), expl.getDetails()[0].getDescription().contains("NaN is an illegal score"));
|
||||
reader.close();
|
||||
dir.close();
|
||||
|
|
|
@ -98,7 +98,7 @@ public class TestPayloadCheckQuery extends LuceneTestCase {
|
|||
SpanQuery query = new SpanPayloadCheckQuery(term1, Collections.singletonList(pay));
|
||||
checkHits(query, new int[]
|
||||
{1125, 1135, 1145, 1155, 1165, 1175, 1185, 1195, 1225, 1235, 1245, 1255, 1265, 1275, 1285, 1295, 1325, 1335, 1345, 1355, 1365, 1375, 1385, 1395, 1425, 1435, 1445, 1455, 1465, 1475, 1485, 1495, 1525, 1535, 1545, 1555, 1565, 1575, 1585, 1595, 1625, 1635, 1645, 1655, 1665, 1675, 1685, 1695, 1725, 1735, 1745, 1755, 1765, 1775, 1785, 1795, 1825, 1835, 1845, 1855, 1865, 1875, 1885, 1895, 1925, 1935, 1945, 1955, 1965, 1975, 1985, 1995});
|
||||
assertTrue(searcher.explain(query, 1125).getValue() > 0.0f);
|
||||
assertTrue(searcher.explain(query, 1125).getValue().doubleValue() > 0.0f);
|
||||
|
||||
SpanTermQuery term2 = new SpanTermQuery(new Term("field", "hundred"));
|
||||
SpanNearQuery snq;
|
||||
|
|
|
@ -150,7 +150,7 @@ public final class CoveringQuery extends Query {
|
|||
Explanation subExpl = weight.explain(context, doc);
|
||||
if (subExpl.isMatch()) {
|
||||
freq++;
|
||||
score += subExpl.getValue();
|
||||
score += subExpl.getValue().doubleValue();
|
||||
}
|
||||
subExpls.add(subExpl);
|
||||
}
|
||||
|
|
|
@ -104,7 +104,7 @@ public abstract class BBoxSimilarityValueSource extends DoubleValuesSource {
|
|||
|
||||
@Override
|
||||
public Explanation explain(LeafReaderContext ctx, int docId, Explanation scoreExplanation) throws IOException {
|
||||
DoubleValues dv = getValues(ctx, DoubleValuesSource.constant(scoreExplanation.getValue()).getValues(ctx, null));
|
||||
DoubleValues dv = getValues(ctx, DoubleValuesSource.constant(scoreExplanation.getValue().doubleValue()).getValues(ctx, null));
|
||||
if (dv.advanceExact(docId)) {
|
||||
AtomicReference<Explanation> explanation = new AtomicReference<>();
|
||||
final ShapeValues shapeValues = bboxValueSource.getValues(ctx);
|
||||
|
|
|
@ -77,7 +77,7 @@ public class ReciprocalDoubleValuesSource extends DoubleValuesSource {
|
|||
@Override
|
||||
public Explanation explain(LeafReaderContext ctx, int docId, Explanation scoreExplanation) throws IOException {
|
||||
Explanation expl = input.explain(ctx, docId, scoreExplanation);
|
||||
return Explanation.match((float)recip(expl.getValue()),
|
||||
return Explanation.match(recip(expl.getValue().doubleValue()),
|
||||
distToEdge + " / (v + " + distToEdge + "), computed from:", expl);
|
||||
}
|
||||
|
||||
|
|
|
@ -316,7 +316,7 @@ public class CheckHits {
|
|||
float score,
|
||||
boolean deep,
|
||||
Explanation expl) {
|
||||
float value = expl.getValue();
|
||||
float value = expl.getValue().floatValue();
|
||||
// TODO: clean this up if we use junit 5 (the assert message is costly)
|
||||
try {
|
||||
Assert.assertEquals(score, value, 0d);
|
||||
|
@ -382,7 +382,7 @@ public class CheckHits {
|
|||
float max = Float.NEGATIVE_INFINITY;
|
||||
double maxError = 0;
|
||||
for (int i=0; i<detail.length; i++) {
|
||||
float dval = detail[i].getValue();
|
||||
float dval = detail[i].getValue().floatValue();
|
||||
verifyExplanation(q,doc,dval,deep,detail[i]);
|
||||
product *= dval;
|
||||
sum += dval;
|
||||
|
|
|
@ -110,13 +110,13 @@ public class AssertingSimilarity extends Similarity {
|
|||
assert doc < context.reader().maxDoc();
|
||||
// freq in bounds
|
||||
assert freq != null;
|
||||
assert Float.isFinite(freq.getValue());
|
||||
assert Float.isFinite(freq.getValue().floatValue());
|
||||
// result in bounds
|
||||
Explanation explanation = delegateScorer.explain(doc, freq);
|
||||
assert explanation != null;
|
||||
assert Float.isFinite(explanation.getValue());
|
||||
assert Float.isFinite(explanation.getValue().floatValue());
|
||||
// result matches score exactly
|
||||
assert explanation.getValue() == delegateScorer.score(doc, freq.getValue());
|
||||
assert explanation.getValue().floatValue() == delegateScorer.score(doc, freq.getValue().floatValue());
|
||||
return explanation;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -452,7 +452,7 @@ public abstract class BaseSimilarityTestCase extends LuceneTestCase {
|
|||
assertTrue("score > maxScore: " + score + " > " + maxScore, score <= maxScore);
|
||||
// check explanation matches
|
||||
Explanation explanation = scorer.explain(0, Explanation.match(freq, "freq, occurrences of term within document"));
|
||||
if (score != explanation.getValue()) {
|
||||
if (score != explanation.getValue().doubleValue()) {
|
||||
fail("expected: " + score + ", got: " + explanation);
|
||||
}
|
||||
CheckHits.verifyExplanation("<test query>", 0, score, true, explanation);
|
||||
|
@ -473,7 +473,7 @@ public abstract class BaseSimilarityTestCase extends LuceneTestCase {
|
|||
assertTrue(prevScore >= 0);
|
||||
// check explanation matches
|
||||
Explanation prevExplanation = scorer.explain(0, Explanation.match(prevFreq, "freq, occurrences of term within document"));
|
||||
if (prevScore != prevExplanation.getValue()) {
|
||||
if (prevScore != prevExplanation.getValue().doubleValue()) {
|
||||
fail("expected: " + prevScore + ", got: " + prevExplanation);
|
||||
}
|
||||
CheckHits.verifyExplanation("test query (prevFreq)", 0, prevScore, true, prevExplanation);
|
||||
|
@ -493,7 +493,7 @@ public abstract class BaseSimilarityTestCase extends LuceneTestCase {
|
|||
assertTrue(prevNormScore >= 0);
|
||||
// check explanation matches
|
||||
Explanation prevNormExplanation = prevNormScorer.explain(0, Explanation.match(freq, "freq, occurrences of term within document"));
|
||||
if (prevNormScore != prevNormExplanation.getValue()) {
|
||||
if (prevNormScore != prevNormExplanation.getValue().doubleValue()) {
|
||||
fail("expected: " + prevNormScore + ", got: " + prevNormExplanation);
|
||||
}
|
||||
CheckHits.verifyExplanation("test query (prevNorm)", 0, prevNormScore, true, prevNormExplanation);
|
||||
|
@ -516,7 +516,7 @@ public abstract class BaseSimilarityTestCase extends LuceneTestCase {
|
|||
assertTrue(prevTermScore >= 0);
|
||||
// check explanation matches
|
||||
Explanation prevTermExplanation = prevTermScorer.explain(0, Explanation.match(freq, "freq, occurrences of term within document"));
|
||||
if (prevTermScore != prevTermExplanation.getValue()) {
|
||||
if (prevTermScore != prevTermExplanation.getValue().doubleValue()) {
|
||||
fail("expected: " + prevTermScore + ", got: " + prevTermExplanation);
|
||||
}
|
||||
CheckHits.verifyExplanation("test query (prevTerm)", 0, prevTermScore, true, prevTermExplanation);
|
||||
|
|
|
@ -89,7 +89,7 @@ public class TestBaseExplanationTestCase extends BaseExplanationTestCase {
|
|||
Explanation result = in.explain(context, doc);
|
||||
if (result.isMatch()) {
|
||||
if (q.breakExplainScores) {
|
||||
result = Explanation.match(-1F * result.getValue(), "Broken Explanation Score", result);
|
||||
result = Explanation.match(-1F * result.getValue().doubleValue(), "Broken Explanation Score", result);
|
||||
}
|
||||
if (q.toggleExplainMatch) {
|
||||
result = Explanation.noMatch("Broken Explanation Matching", result);
|
||||
|
|
|
@ -129,7 +129,7 @@ public class LinearModel extends LTRScoringModel {
|
|||
"weight on feature"));
|
||||
featureDetails.add(featureExplain);
|
||||
|
||||
details.add(Explanation.match(featureExplain.getValue()
|
||||
details.add(Explanation.match(featureExplain.getValue().doubleValue()
|
||||
* featureToWeight[index], "prod of:", featureDetails));
|
||||
index++;
|
||||
}
|
||||
|
|
|
@ -345,7 +345,7 @@ public class MultipleAdditiveTreesModel extends LTRScoringModel {
|
|||
final float[] fv = new float[featureExplanations.size()];
|
||||
int index = 0;
|
||||
for (final Explanation featureExplain : featureExplanations) {
|
||||
fv[index] = featureExplain.getValue();
|
||||
fv[index] = featureExplain.getValue().floatValue();
|
||||
index++;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ public abstract class Normalizer {
|
|||
public abstract LinkedHashMap<String,Object> paramsToMap();
|
||||
|
||||
public Explanation explain(Explanation explain) {
|
||||
final float normalized = normalize(explain.getValue());
|
||||
final float normalized = normalize(explain.getValue().floatValue());
|
||||
final String explainDesc = "normalized using " + toString();
|
||||
|
||||
return Explanation.match(normalized, explainDesc, explain);
|
||||
|
|
|
@ -497,7 +497,7 @@ class SpatialDistanceQuery extends ExtendedQueryBase implements PostFilter {
|
|||
double dist = dist(latVals.doubleVal(doc), lonVals.doubleVal(doc));
|
||||
|
||||
String description = SpatialDistanceQuery.this.toString();
|
||||
return Explanation.match((float) (base.getValue() * dist), description + " product of:",
|
||||
return Explanation.match((float) (base.getValue().floatValue() * dist), description + " product of:",
|
||||
base, Explanation.match((float) dist, "hsin("+latVals.doubleVal(doc)+","+lonVals.doubleVal(doc)));
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ public class TestSweetSpotSimilarityFactory extends BaseSimilarityTestCase {
|
|||
dir.close();
|
||||
Explanation norm = findExplanation(expl, "fieldNorm");
|
||||
assertNotNull(norm);
|
||||
return norm.getValue();
|
||||
return norm.getValue().floatValue();
|
||||
}
|
||||
|
||||
private static Explanation findExplanation(Explanation expl, String text) {
|
||||
|
|
Loading…
Reference in New Issue