Skip to content

Commit 0566926

Browse files
authored
Remove tf() painless method (#9995)
Signed-off-by: Louis Chu <clingzhi@amazon.com>
1 parent c261cff commit 0566926

File tree

3 files changed

+0
-34
lines changed

3 files changed

+0
-34
lines changed

modules/lang-painless/src/main/resources/org/opensearch/painless/spi/org.opensearch.score.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ class org.opensearch.script.ScoreScript @no_import {
2424

2525
static_import {
2626
int termFreq(org.opensearch.script.ScoreScript, String, String) bound_to org.opensearch.script.ScoreScriptUtils$TermFreq
27-
float tf(org.opensearch.script.ScoreScript, String, String) bound_to org.opensearch.script.ScoreScriptUtils$TF
2827
long totalTermFreq(org.opensearch.script.ScoreScript, String, String) bound_to org.opensearch.script.ScoreScriptUtils$TotalTermFreq
2928
long sumTotalTermFreq(org.opensearch.script.ScoreScript, String) bound_to org.opensearch.script.ScoreScriptUtils$SumTotalTermFreq
3029
double saturation(double, double) from_class org.opensearch.script.ScoreScriptUtils

server/src/main/java/org/opensearch/index/query/functionscore/TermFrequencyFunctionFactory.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import org.apache.lucene.index.LeafReaderContext;
1212
import org.apache.lucene.queries.function.FunctionValues;
1313
import org.apache.lucene.queries.function.valuesource.SumTotalTermFreqValueSource;
14-
import org.apache.lucene.queries.function.valuesource.TFValueSource;
1514
import org.apache.lucene.queries.function.valuesource.TermFreqValueSource;
1615
import org.apache.lucene.queries.function.valuesource.TotalTermFreqValueSource;
1716
import org.apache.lucene.search.IndexSearcher;
@@ -42,15 +41,6 @@ public static TermFrequencyFunction createFunction(
4241
TermFreqValueSource termFreqValueSource = new TermFreqValueSource(field, term, field, BytesRefs.toBytesRef(term));
4342
FunctionValues functionValues = termFreqValueSource.getValues(null, readerContext);
4443
return docId -> functionValues.intVal(docId);
45-
case TF:
46-
TFValueSource tfValueSource = new TFValueSource(field, term, field, BytesRefs.toBytesRef(term));
47-
Map<Object, Object> tfContext = new HashMap<>() {
48-
{
49-
put("searcher", indexSearcher);
50-
}
51-
};
52-
functionValues = tfValueSource.getValues(tfContext, readerContext);
53-
return docId -> functionValues.floatVal(docId);
5444
case TOTAL_TERM_FREQ:
5545
TotalTermFreqValueSource totalTermFreqValueSource = new TotalTermFreqValueSource(
5646
field,
@@ -78,7 +68,6 @@ public static TermFrequencyFunction createFunction(
7868
*/
7969
public enum TermFrequencyFunctionName {
8070
TERM_FREQ("termFreq"),
81-
TF("tf"),
8271
TOTAL_TERM_FREQ("totalTermFreq"),
8372
SUM_TOTAL_TERM_FREQ("sumTotalTermFreq");
8473

server/src/main/java/org/opensearch/script/ScoreScriptUtils.java

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
import static org.opensearch.common.util.BitMixer.mix32;
5151
import static org.opensearch.index.query.functionscore.TermFrequencyFunctionFactory.TermFrequencyFunctionName.SUM_TOTAL_TERM_FREQ;
5252
import static org.opensearch.index.query.functionscore.TermFrequencyFunctionFactory.TermFrequencyFunctionName.TERM_FREQ;
53-
import static org.opensearch.index.query.functionscore.TermFrequencyFunctionFactory.TermFrequencyFunctionName.TF;
5453
import static org.opensearch.index.query.functionscore.TermFrequencyFunctionFactory.TermFrequencyFunctionName.TOTAL_TERM_FREQ;
5554

5655
/**
@@ -95,27 +94,6 @@ public int termFreq(String field, String term) {
9594
}
9695
}
9796

98-
/**
99-
* Calculates the term frequency-inverse document frequency (tf-idf) for a specific term within a field.
100-
*
101-
* @opensearch.internal
102-
*/
103-
public static final class TF {
104-
private final ScoreScript scoreScript;
105-
106-
public TF(ScoreScript scoreScript) {
107-
this.scoreScript = scoreScript;
108-
}
109-
110-
public float tf(String field, String term) {
111-
try {
112-
return (float) scoreScript.getTermFrequency(TF, field, term);
113-
} catch (Exception e) {
114-
throw ExceptionsHelper.convertToOpenSearchException(e);
115-
}
116-
}
117-
}
118-
11997
/**
12098
* Retrieves the total term frequency within a field for a specific term.
12199
*

0 commit comments

Comments
 (0)