Skip to content

Commit

Permalink
Fixed failing integ tests
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Gaievski <gaievski@amazon.com>
  • Loading branch information
martin-gaievski committed Dec 6, 2023
1 parent 0236cc3 commit d754563
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/test/java/org/opensearch/neuralsearch/query/NeuralQueryIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

package org.opensearch.neuralsearch.query;

import static org.opensearch.neuralsearch.TestUtils.DELTA_FOR_SCORE_ASSERTION;
import static org.opensearch.neuralsearch.TestUtils.createRandomVector;
import static org.opensearch.neuralsearch.TestUtils.objectToFloat;

import java.io.IOException;
import java.util.Collections;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -92,7 +92,7 @@ public void testBasicQuery() {

assertEquals("1", firstInnerHit.get("_id"));
float expectedScore = computeExpectedScore(modelId, testVector, TEST_SPACE_TYPE, TEST_QUERY_TEXT);
assertEquals(expectedScore, objectToFloat(firstInnerHit.get("_score")), 0.0);
assertEquals(expectedScore, objectToFloat(firstInnerHit.get("_score")), DELTA_FOR_SCORE_ASSERTION);
}

/**
Expand Down Expand Up @@ -131,7 +131,7 @@ public void testBoostQuery() {

assertEquals("1", firstInnerHit.get("_id"));
float expectedScore = 2 * computeExpectedScore(modelId, testVector, TEST_SPACE_TYPE, TEST_QUERY_TEXT);
assertEquals(expectedScore, objectToFloat(firstInnerHit.get("_score")), 0.0);
assertEquals(expectedScore, objectToFloat(firstInnerHit.get("_score")), DELTA_FOR_SCORE_ASSERTION);
}

/**
Expand Down Expand Up @@ -174,7 +174,7 @@ public void testRescoreQuery() {

assertEquals("1", firstInnerHit.get("_id"));
float expectedScore = computeExpectedScore(modelId, testVector, TEST_SPACE_TYPE, TEST_QUERY_TEXT);
assertEquals(expectedScore, objectToFloat(firstInnerHit.get("_score")), 0.0);
assertEquals(expectedScore, objectToFloat(firstInnerHit.get("_score")), DELTA_FOR_SCORE_ASSERTION);
}

/**
Expand Down Expand Up @@ -234,7 +234,7 @@ public void testBooleanQuery_withMultipleNeuralQueries() {

assertEquals("1", firstInnerHit.get("_id"));
float expectedScore = 2 * computeExpectedScore(modelId, testVector, TEST_SPACE_TYPE, TEST_QUERY_TEXT);
assertEquals(expectedScore, objectToFloat(firstInnerHit.get("_score")), 0.0);
assertEquals(expectedScore, objectToFloat(firstInnerHit.get("_score")), DELTA_FOR_SCORE_ASSERTION);
}

/**
Expand Down Expand Up @@ -326,7 +326,7 @@ public void testNestedQuery() {

assertEquals("1", firstInnerHit.get("_id"));
float expectedScore = computeExpectedScore(modelId, testVector, TEST_SPACE_TYPE, TEST_QUERY_TEXT);
assertEquals(expectedScore, objectToFloat(firstInnerHit.get("_score")), 0.0);
assertEquals(expectedScore, objectToFloat(firstInnerHit.get("_score")), DELTA_FOR_SCORE_ASSERTION);
}

/**
Expand Down Expand Up @@ -368,7 +368,7 @@ public void testFilterQuery() {
Map<String, Object> firstInnerHit = getFirstInnerHit(searchResponseAsMap);
assertEquals("3", firstInnerHit.get("_id"));
float expectedScore = computeExpectedScore(modelId, testVector, TEST_SPACE_TYPE, TEST_QUERY_TEXT);
assertEquals(expectedScore, objectToFloat(firstInnerHit.get("_score")), 0.0);
assertEquals(expectedScore, objectToFloat(firstInnerHit.get("_score")), DELTA_FOR_SCORE_ASSERTION);
}

/**
Expand Down Expand Up @@ -404,10 +404,11 @@ public void testMultimodalQuery() {

assertEquals("1", firstInnerHit.get("_id"));
float expectedScore = computeExpectedScore(modelId, testVector, TEST_SPACE_TYPE, TEST_QUERY_TEXT);
assertEquals(expectedScore, objectToFloat(firstInnerHit.get("_score")), 0.0);
assertEquals(expectedScore, objectToFloat(firstInnerHit.get("_score")), DELTA_FOR_SCORE_ASSERTION);
}

private void initializeIndexIfNotExist(String indexName) throws IOException {
@SneakyThrows
private void initializeIndexIfNotExist(String indexName) {
if (TEST_BASIC_INDEX_NAME.equals(indexName) && !indexExists(TEST_BASIC_INDEX_NAME)) {
prepareKnnIndex(
TEST_BASIC_INDEX_NAME,
Expand Down

0 comments on commit d754563

Please sign in to comment.