From 6a0bb56132e264ff91a0503308836d191b6b563e Mon Sep 17 00:00:00 2001 From: zhichao-aws Date: Mon, 30 Oct 2023 10:39:51 +0800 Subject: [PATCH] deprecate max_token_score Signed-off-by: zhichao-aws --- .../query/NeuralSparseQueryBuilder.java | 7 +++-- .../query/NeuralSparseQueryBuilderTests.java | 26 +++++++++++++++++++ .../query/NeuralSparseQueryIT.java | 11 +------- 3 files changed, 30 insertions(+), 14 deletions(-) diff --git a/src/main/java/org/opensearch/neuralsearch/query/NeuralSparseQueryBuilder.java b/src/main/java/org/opensearch/neuralsearch/query/NeuralSparseQueryBuilder.java index 2373ad060..1274107b7 100644 --- a/src/main/java/org/opensearch/neuralsearch/query/NeuralSparseQueryBuilder.java +++ b/src/main/java/org/opensearch/neuralsearch/query/NeuralSparseQueryBuilder.java @@ -61,8 +61,10 @@ public class NeuralSparseQueryBuilder extends AbstractQueryBuilder firstInnerHit = getFirstInnerHit(searchResponseAsMap); assertEquals("1", firstInnerHit.get("_id")); - Map queryTokens = runSparseModelInference(modelId, TEST_QUERY_TEXT); - float expectedScore = 0f; - for (Map.Entry entry : queryTokens.entrySet()) { - if (testRankFeaturesDoc.containsKey(entry.getKey())) { - expectedScore += entry.getValue() * Math.min( - getFeatureFieldCompressedNumber(testRankFeaturesDoc.get(entry.getKey())), - maxTokenScore - ); - } - } + float expectedScore = computeExpectedScore(modelId, testRankFeaturesDoc, TEST_QUERY_TEXT); assertEquals(expectedScore, objectToFloat(firstInnerHit.get("_score")), DELTA); }