Skip to content

Commit

Permalink
Fixed unit test for neural query after recent knn change in rescore c…
Browse files Browse the repository at this point in the history
…ontext (#927) (#929)

Signed-off-by: Martin Gaievski <[email protected]>
(cherry picked from commit ba94f75)

Co-authored-by: Martin Gaievski <[email protected]>
  • Loading branch information
1 parent fe50537 commit 11681e4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import static org.opensearch.knn.index.query.KNNQueryBuilder.MIN_SCORE_FIELD;
import static org.opensearch.knn.index.query.KNNQueryBuilder.RESCORE_FIELD;
import static org.opensearch.knn.index.query.KNNQueryBuilder.RESCORE_OVERSAMPLE_FIELD;
import static org.opensearch.neuralsearch.util.TestUtils.DELTA_FOR_FLOATS_ASSERTION;
import static org.opensearch.neuralsearch.util.TestUtils.xContentBuilderToMap;
import static org.opensearch.neuralsearch.query.NeuralQueryBuilder.K_FIELD;
import static org.opensearch.neuralsearch.query.NeuralQueryBuilder.MODEL_ID_FIELD;
Expand Down Expand Up @@ -183,7 +184,11 @@ public void testFromXContent_withRescoreContext_thenBuildSuccessfully() {
assertEquals(QUERY_TEXT, neuralQueryBuilder.queryText());
assertEquals(MODEL_ID, neuralQueryBuilder.modelId());
assertEquals(K, neuralQueryBuilder.k());
assertEquals(RescoreContext.getDefault(), neuralQueryBuilder.rescoreContext());
assertEquals(
RescoreContext.getDefault().getOversampleFactor(),
neuralQueryBuilder.rescoreContext().getOversampleFactor(),
DELTA_FOR_FLOATS_ASSERTION
);
assertNull(neuralQueryBuilder.methodParameters());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class TestUtils {

public static final String RELATION_EQUAL_TO = "eq";
public static final float DELTA_FOR_SCORE_ASSERTION = 0.001f;
public static final float DELTA_FOR_FLOATS_ASSERTION = 0.001f;
public static final String RESTART_UPGRADE_OLD_CLUSTER = "tests.is_old_cluster";
public static final String BWC_VERSION = "tests.plugin_bwc_version";
public static final String NEURAL_SEARCH_BWC_PREFIX = "neuralsearch-bwc-";
Expand Down

0 comments on commit 11681e4

Please sign in to comment.