Skip to content

Apache Lucene open-source search software

LUCENE-8014: Deprecate SimScorer.computeSlopFactor and computePayloadFactor

Alan Woodwardbba2b6d418e0
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index a3d6756ee5a..0f44ab7df53 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -46,6 +46,9 @@ API Changes
calculated by a PayloadDecoder, instead of delegating to the Similarity.
(Alan Woodward)
+* LUCENE-8014: Similarity.computeSlopFactor() and
+ Similarity.computePayloadFactor() have been deprecated. (Alan Woodward)
+
Bug Fixes
* LUCENE-7991: KNearestNeighborDocumentClassifier.knnSearch no longer applies
diff --git a/lucene/core/src/java/org/apache/lucene/search/similarities/Similarity.java b/lucene/core/src/java/org/apache/lucene/search/similarities/Similarity.java
index 7f0f27c5c5d..64381e222e9 100644
--- a/lucene/core/src/java/org/apache/lucene/search/similarities/Similarity.java
+++ b/lucene/core/src/java/org/apache/lucene/search/similarities/Similarity.java
@@ -17,6 +17,9 @@
package org.apache.lucene.search.similarities;
+import java.io.IOException;
+import java.util.Collections;
+
import org.apache.lucene.index.FieldInvertState;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.search.CollectionStatistics;
@@ -29,9 +32,6 @@ import org.apache.lucene.search.spans.SpanQuery;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.SmallFloat;
-import java.io.IOException;
-import java.util.Collections;
-
/**
* Similarity defines the components of Lucene scoring.
* <p>
@@ -142,10 +142,6 @@ public abstract class Similarity {
/**
* API for scoring "sloppy" queries such as {@link TermQuery},
* {@link SpanQuery}, and {@link PhraseQuery}.
- * <p>
- * Frequencies are floating-point values: an approximate
- * within-document frequency adjusted for "sloppiness" by
- * {@link SimScorer#computeSlopFactor(int)}.
*/
public static abstract class SimScorer {
@@ -164,9 +160,11 @@ public abstract class Similarity {
public abstract float score(int doc, float freq) throws IOException;
/** Computes the amount of a sloppy phrase match, based on an edit distance. */
+ @Deprecated
public abstract float computeSlopFactor(int distance);
/** Calculate a scoring factor based on the data in the payload. */
+ @Deprecated
public abstract float computePayloadFactor(int doc, int start, int end, BytesRef payload);
/**