Skip to content

Commit

Permalink
Fixed failed test after knn pushed multiple inner hits feature (#1026)
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Gaievski <[email protected]>
  • Loading branch information
martin-gaievski authored Dec 17, 2024
1 parent 393d49a commit 3d72cc3
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
import org.opensearch.knn.index.mapper.KNNVectorFieldType;
import org.opensearch.knn.index.query.KNNQuery;
import org.opensearch.knn.index.query.KNNQueryBuilder;
import org.opensearch.knn.index.query.nativelib.NativeEngineKnnVectorQuery;
import org.opensearch.neuralsearch.util.NeuralSearchClusterTestUtils;
import org.opensearch.neuralsearch.util.NeuralSearchClusterUtil;

Expand Down Expand Up @@ -141,8 +142,8 @@ public void testDoToQuery_whenOneSubquery_thenBuildSuccessfully() {
assertNotNull(queryOnlyNeural);
assertTrue(queryOnlyNeural instanceof HybridQuery);
assertEquals(1, ((HybridQuery) queryOnlyNeural).getSubQueries().size());
assertTrue(((HybridQuery) queryOnlyNeural).getSubQueries().iterator().next() instanceof KNNQuery);
KNNQuery knnQuery = (KNNQuery) ((HybridQuery) queryOnlyNeural).getSubQueries().iterator().next();
assertTrue(((HybridQuery) queryOnlyNeural).getSubQueries().iterator().next() instanceof NativeEngineKnnVectorQuery);
KNNQuery knnQuery = ((NativeEngineKnnVectorQuery) ((HybridQuery) queryOnlyNeural).getSubQueries().iterator().next()).getKnnQuery();
assertEquals(VECTOR_FIELD_NAME, knnQuery.getField());
assertEquals(K, knnQuery.getK());
assertNotNull(knnQuery.getQueryVector());
Expand Down Expand Up @@ -183,8 +184,8 @@ public void testDoToQuery_whenMultipleSubqueries_thenBuildSuccessfully() {
// verify knn vector query
Iterator<Query> queryIterator = ((HybridQuery) queryTwoSubQueries).getSubQueries().iterator();
Query firstQuery = queryIterator.next();
assertTrue(firstQuery instanceof KNNQuery);
KNNQuery knnQuery = (KNNQuery) firstQuery;
assertTrue(firstQuery instanceof NativeEngineKnnVectorQuery);
KNNQuery knnQuery = ((NativeEngineKnnVectorQuery) firstQuery).getKnnQuery();
assertEquals(VECTOR_FIELD_NAME, knnQuery.getField());
assertEquals(K, knnQuery.getK());
assertNotNull(knnQuery.getQueryVector());
Expand Down

0 comments on commit 3d72cc3

Please sign in to comment.