From 3e9fff3a3d3171d83f5ba39aa7be77220483372e Mon Sep 17 00:00:00 2001 From: Varun Jain Date: Mon, 29 Jan 2024 14:17:41 -0800 Subject: [PATCH] Addressing Heemin's comment: Signed-off-by: Varun Jain --- .../NeuralQueryEnricherProcessorIT.java | 31 +++++-------- .../processor/NormalizationProcessorIT.java | 25 ++++------ .../processor/ScoreCombinationIT.java | 20 +++----- .../processor/ScoreNormalizationIT.java | 15 ++---- .../processor/SparseEncodingProcessIT.java | 20 ++------ .../processor/TextEmbeddingProcessorIT.java | 20 ++------ .../TextImageEmbeddingProcessorIT.java | 18 ++------ .../neuralsearch/query/HybridQueryIT.java | 46 ++++++++----------- .../neuralsearch/query/NeuralQueryIT.java | 39 +++++++--------- .../query/NeuralSparseQueryIT.java | 28 +++++------ 10 files changed, 86 insertions(+), 176 deletions(-) diff --git a/src/test/java/org/opensearch/neuralsearch/processor/NeuralQueryEnricherProcessorIT.java b/src/test/java/org/opensearch/neuralsearch/processor/NeuralQueryEnricherProcessorIT.java index 758e57a09..35dcc8a67 100644 --- a/src/test/java/org/opensearch/neuralsearch/processor/NeuralQueryEnricherProcessorIT.java +++ b/src/test/java/org/opensearch/neuralsearch/processor/NeuralQueryEnricherProcessorIT.java @@ -11,7 +11,6 @@ import java.util.Collections; import java.util.Map; -import org.junit.After; import org.junit.Before; import org.opensearch.common.settings.Settings; import org.opensearch.neuralsearch.BaseNeuralSearchIT; @@ -29,27 +28,17 @@ public class NeuralQueryEnricherProcessorIT extends BaseNeuralSearchIT { private static final String ingest_pipeline = "nlp-pipeline"; private static final String TEST_KNN_VECTOR_FIELD_NAME_1 = "test-knn-vector-1"; private final float[] testVector = createRandomVector(TEST_DIMENSION); - private String modelId; @Before public void setUp() throws Exception { super.setUp(); updateClusterSettings(); - modelId = prepareModel(); - } - - @After - @SneakyThrows - public void tearDown() { - super.tearDown(); - deleteSearchPipeline(search_pipeline); - deleteModel(modelId); - deleteIndex(index); } @SneakyThrows public void testNeuralQueryEnricherProcessor_whenNoModelIdPassed_thenSuccess() { - initializeIndexIfNotExist(); + initializeIndexIfNotExist(index); + String modelId = prepareModel(); createSearchRequestProcessor(modelId, search_pipeline); createPipelineProcessor(modelId, ingest_pipeline, ProcessorType.TEXT_EMBEDDING); updateIndexSettings(index, Settings.builder().put("index.search.default_pipeline", search_pipeline)); @@ -60,12 +49,13 @@ public void testNeuralQueryEnricherProcessor_whenNoModelIdPassed_thenSuccess() { Map response = search(index, neuralQueryBuilder, 2); assertFalse(response.isEmpty()); - + wipeOfTestResources(index, ingest_pipeline, modelId, search_pipeline); } @SneakyThrows public void testNeuralQueryEnricherProcessor_whenHybridQueryBuilderAndNoModelIdPassed_thenSuccess() { - initializeIndexIfNotExist(); + initializeIndexIfNotExist(index); + String modelId = prepareModel(); createSearchRequestProcessor(modelId, search_pipeline); createPipelineProcessor(modelId, ingest_pipeline, ProcessorType.TEXT_EMBEDDING); updateIndexSettings(index, Settings.builder().put("index.search.default_pipeline", search_pipeline)); @@ -78,23 +68,24 @@ public void testNeuralQueryEnricherProcessor_whenHybridQueryBuilderAndNoModelIdP Map response = search(index, hybridQueryBuilder, 2); assertFalse(response.isEmpty()); + wipeOfTestResources(index, ingest_pipeline, modelId, search_pipeline); } @SneakyThrows - private void initializeIndexIfNotExist() { - if (index.equals(NeuralQueryEnricherProcessorIT.index) && !indexExists(index)) { + private void initializeIndexIfNotExist(String indexName) { + if (indexName.equals(NeuralQueryEnricherProcessorIT.index) && !indexExists(indexName)) { prepareKnnIndex( - index, + indexName, Collections.singletonList(new KNNFieldConfig(TEST_KNN_VECTOR_FIELD_NAME_1, TEST_DIMENSION, TEST_SPACE_TYPE)) ); addKnnDoc( - index, + indexName, "1", Collections.singletonList(TEST_KNN_VECTOR_FIELD_NAME_1), Collections.singletonList(Floats.asList(testVector).toArray()) ); - assertEquals(1, getDocCount(index)); + assertEquals(1, getDocCount(indexName)); } } } diff --git a/src/test/java/org/opensearch/neuralsearch/processor/NormalizationProcessorIT.java b/src/test/java/org/opensearch/neuralsearch/processor/NormalizationProcessorIT.java index f71c22aed..41918dbd6 100644 --- a/src/test/java/org/opensearch/neuralsearch/processor/NormalizationProcessorIT.java +++ b/src/test/java/org/opensearch/neuralsearch/processor/NormalizationProcessorIT.java @@ -19,7 +19,6 @@ import java.util.stream.IntStream; import org.apache.commons.lang3.Range; -import org.junit.After; import org.junit.Before; import org.opensearch.index.query.QueryBuilders; import org.opensearch.index.query.TermQueryBuilder; @@ -53,20 +52,11 @@ public class NormalizationProcessorIT extends BaseNeuralSearchIT { private final float[] testVector2 = createRandomVector(TEST_DIMENSION); private final float[] testVector3 = createRandomVector(TEST_DIMENSION); private final float[] testVector4 = createRandomVector(TEST_DIMENSION); - private String modelId; @Before public void setUp() throws Exception { super.setUp(); - modelId = prepareModel(); - } - - @After - @SneakyThrows - public void tearDown() { - super.tearDown(); - deleteSearchPipeline(SEARCH_PIPELINE); - deleteModel(modelId); + updateClusterSettings(); } /** @@ -90,6 +80,7 @@ public void tearDown() { @SneakyThrows public void testResultProcessor_whenOneShardAndQueryMatches_thenSuccessful() { initializeIndexIfNotExist(TEST_MULTI_DOC_INDEX_ONE_SHARD_NAME); + String modelId = prepareModel(); createSearchPipelineWithResultsPostProcessor(SEARCH_PIPELINE); NeuralQueryBuilder neuralQueryBuilder = new NeuralQueryBuilder( @@ -115,7 +106,7 @@ public void testResultProcessor_whenOneShardAndQueryMatches_thenSuccessful() { Map.of("search_pipeline", SEARCH_PIPELINE) ); assertQueryResults(searchResponseAsMap, 5, false); - deleteIndex(TEST_MULTI_DOC_INDEX_ONE_SHARD_NAME); + wipeOfTestResources(TEST_MULTI_DOC_INDEX_ONE_SHARD_NAME, null, modelId, SEARCH_PIPELINE); } /** @@ -133,6 +124,7 @@ public void testResultProcessor_whenOneShardAndQueryMatches_thenSuccessful() { @SneakyThrows public void testResultProcessor_whenDefaultProcessorConfigAndQueryMatches_thenSuccessful() { initializeIndexIfNotExist(TEST_MULTI_DOC_INDEX_ONE_SHARD_NAME); + String modelId = prepareModel(); createSearchPipelineWithDefaultResultsPostProcessor(SEARCH_PIPELINE); NeuralQueryBuilder neuralQueryBuilder = new NeuralQueryBuilder( @@ -158,12 +150,13 @@ public void testResultProcessor_whenDefaultProcessorConfigAndQueryMatches_thenSu Map.of("search_pipeline", SEARCH_PIPELINE) ); assertQueryResults(searchResponseAsMap, 5, false); - deleteIndex(TEST_MULTI_DOC_INDEX_ONE_SHARD_NAME); + wipeOfTestResources(TEST_MULTI_DOC_INDEX_ONE_SHARD_NAME, null, modelId, SEARCH_PIPELINE); } @SneakyThrows public void testResultProcessor_whenMultipleShardsAndQueryMatches_thenSuccessful() { initializeIndexIfNotExist(TEST_MULTI_DOC_INDEX_THREE_SHARDS_NAME); + String modelId = prepareModel(); createSearchPipelineWithResultsPostProcessor(SEARCH_PIPELINE); int totalExpectedDocQty = 6; @@ -218,7 +211,7 @@ public void testResultProcessor_whenMultipleShardsAndQueryMatches_thenSuccessful // verify that all ids are unique assertEquals(Set.copyOf(ids).size(), ids.size()); - deleteIndex(TEST_MULTI_DOC_INDEX_THREE_SHARDS_NAME); + wipeOfTestResources(TEST_MULTI_DOC_INDEX_THREE_SHARDS_NAME, null, modelId, SEARCH_PIPELINE); } @SneakyThrows @@ -238,7 +231,7 @@ public void testResultProcessor_whenMultipleShardsAndNoMatches_thenSuccessful() Map.of("search_pipeline", SEARCH_PIPELINE) ); assertQueryResults(searchResponseAsMap, 0, true); - deleteIndex(TEST_MULTI_DOC_INDEX_THREE_SHARDS_NAME); + wipeOfTestResources(TEST_MULTI_DOC_INDEX_THREE_SHARDS_NAME, null, null, SEARCH_PIPELINE); } @SneakyThrows @@ -259,7 +252,7 @@ public void testResultProcessor_whenMultipleShardsAndPartialMatches_thenSuccessf Map.of("search_pipeline", SEARCH_PIPELINE) ); assertQueryResults(searchResponseAsMap, 4, true, Range.between(0.33f, 1.0f)); - deleteIndex(TEST_MULTI_DOC_INDEX_THREE_SHARDS_NAME); + wipeOfTestResources(TEST_MULTI_DOC_INDEX_THREE_SHARDS_NAME, null, null, SEARCH_PIPELINE); } private void initializeIndexIfNotExist(String indexName) throws IOException { diff --git a/src/test/java/org/opensearch/neuralsearch/processor/ScoreCombinationIT.java b/src/test/java/org/opensearch/neuralsearch/processor/ScoreCombinationIT.java index 4c1d69daf..042f40065 100644 --- a/src/test/java/org/opensearch/neuralsearch/processor/ScoreCombinationIT.java +++ b/src/test/java/org/opensearch/neuralsearch/processor/ScoreCombinationIT.java @@ -17,7 +17,6 @@ import java.util.Collections; import java.util.Map; -import org.junit.After; import org.junit.Before; import org.opensearch.client.ResponseException; import org.opensearch.index.query.QueryBuilders; @@ -54,20 +53,11 @@ public class ScoreCombinationIT extends BaseNeuralSearchIT { private static final String L2_NORMALIZATION_METHOD = "l2"; private static final String HARMONIC_MEAN_COMBINATION_METHOD = "harmonic_mean"; private static final String GEOMETRIC_MEAN_COMBINATION_METHOD = "geometric_mean"; - private String modelId; @Before public void setUp() throws Exception { super.setUp(); - modelId = prepareModel(); - } - - @After - @SneakyThrows - public void tearDown() { - super.tearDown(); - deleteSearchPipeline(SEARCH_PIPELINE); - deleteModel(modelId); + updateClusterSettings(); } /** @@ -183,7 +173,7 @@ public void testArithmeticWeightedMean_whenWeightsPassed_thenSuccessful() { containsString("in hybrid query") ) ); - deleteIndex(TEST_MULTI_DOC_INDEX_THREE_SHARDS_NAME); + wipeOfTestResources(TEST_MULTI_DOC_INDEX_THREE_SHARDS_NAME, null, null, SEARCH_PIPELINE); } /** @@ -207,6 +197,7 @@ public void testArithmeticWeightedMean_whenWeightsPassed_thenSuccessful() { @SneakyThrows public void testHarmonicMeanCombination_whenOneShardAndQueryMatches_thenSuccessful() { initializeIndexIfNotExist(TEST_MULTI_DOC_INDEX_ONE_SHARD_NAME); + String modelId = prepareModel(); createSearchPipeline( SEARCH_PIPELINE, DEFAULT_NORMALIZATION_METHOD, @@ -249,7 +240,7 @@ public void testHarmonicMeanCombination_whenOneShardAndQueryMatches_thenSuccessf Map.of("search_pipeline", SEARCH_PIPELINE) ); assertHybridSearchResults(searchResponseAsMapL2Norm, 5, new float[] { 0.5f, 1.0f }); - deleteIndex(TEST_MULTI_DOC_INDEX_ONE_SHARD_NAME); + wipeOfTestResources(TEST_MULTI_DOC_INDEX_ONE_SHARD_NAME, null, modelId, SEARCH_PIPELINE); } /** @@ -273,6 +264,7 @@ public void testHarmonicMeanCombination_whenOneShardAndQueryMatches_thenSuccessf @SneakyThrows public void testGeometricMeanCombination_whenOneShardAndQueryMatches_thenSuccessful() { initializeIndexIfNotExist(TEST_MULTI_DOC_INDEX_ONE_SHARD_NAME); + String modelId = prepareModel(); createSearchPipeline( SEARCH_PIPELINE, DEFAULT_NORMALIZATION_METHOD, @@ -315,7 +307,7 @@ public void testGeometricMeanCombination_whenOneShardAndQueryMatches_thenSuccess Map.of("search_pipeline", SEARCH_PIPELINE) ); assertHybridSearchResults(searchResponseAsMapL2Norm, 5, new float[] { 0.5f, 1.0f }); - deleteIndex(TEST_MULTI_DOC_INDEX_ONE_SHARD_NAME); + wipeOfTestResources(TEST_MULTI_DOC_INDEX_ONE_SHARD_NAME, null, modelId, SEARCH_PIPELINE); } private void initializeIndexIfNotExist(String indexName) throws IOException { diff --git a/src/test/java/org/opensearch/neuralsearch/processor/ScoreNormalizationIT.java b/src/test/java/org/opensearch/neuralsearch/processor/ScoreNormalizationIT.java index 8c486f285..0ea25aeff 100644 --- a/src/test/java/org/opensearch/neuralsearch/processor/ScoreNormalizationIT.java +++ b/src/test/java/org/opensearch/neuralsearch/processor/ScoreNormalizationIT.java @@ -14,7 +14,6 @@ import java.util.Collections; import java.util.Map; -import org.junit.After; import org.junit.Before; import org.opensearch.index.query.QueryBuilders; import org.opensearch.neuralsearch.BaseNeuralSearchIT; @@ -46,21 +45,11 @@ public class ScoreNormalizationIT extends BaseNeuralSearchIT { private static final String L2_NORMALIZATION_METHOD = "l2"; private static final String HARMONIC_MEAN_COMBINATION_METHOD = "harmonic_mean"; private static final String GEOMETRIC_MEAN_COMBINATION_METHOD = "geometric_mean"; - private String modelId; @Before public void setUp() throws Exception { super.setUp(); updateClusterSettings(); - modelId = prepareModel(); - } - - @After - @SneakyThrows - public void tearDown() { - super.tearDown(); - deleteSearchPipeline(SEARCH_PIPELINE); - deleteModel(modelId); } @Override @@ -89,6 +78,7 @@ public boolean isUpdateClusterSettings() { @SneakyThrows public void testL2Norm_whenOneShardAndQueryMatches_thenSuccessful() { initializeIndexIfNotExist(TEST_MULTI_DOC_INDEX_ONE_SHARD_NAME); + String modelId = prepareModel(); createSearchPipeline( SEARCH_PIPELINE, L2_NORMALIZATION_METHOD, @@ -160,7 +150,7 @@ public void testL2Norm_whenOneShardAndQueryMatches_thenSuccessful() { Map.of("search_pipeline", SEARCH_PIPELINE) ); assertHybridSearchResults(searchResponseAsMapGeometricMean, 5, new float[] { 0.5f, 1.0f }); - deleteIndex(TEST_MULTI_DOC_INDEX_ONE_SHARD_NAME); + wipeOfTestResources(TEST_MULTI_DOC_INDEX_ONE_SHARD_NAME, null, modelId, SEARCH_PIPELINE); } /** @@ -184,6 +174,7 @@ public void testL2Norm_whenOneShardAndQueryMatches_thenSuccessful() { @SneakyThrows public void testMinMaxNorm_whenOneShardAndQueryMatches_thenSuccessful() { initializeIndexIfNotExist(TEST_MULTI_DOC_INDEX_ONE_SHARD_NAME); + String modelId = prepareModel(); createSearchPipeline( SEARCH_PIPELINE, DEFAULT_NORMALIZATION_METHOD, diff --git a/src/test/java/org/opensearch/neuralsearch/processor/SparseEncodingProcessIT.java b/src/test/java/org/opensearch/neuralsearch/processor/SparseEncodingProcessIT.java index 85a364c79..c0526ce78 100644 --- a/src/test/java/org/opensearch/neuralsearch/processor/SparseEncodingProcessIT.java +++ b/src/test/java/org/opensearch/neuralsearch/processor/SparseEncodingProcessIT.java @@ -11,7 +11,6 @@ import org.apache.hc.core5.http.HttpHeaders; import org.apache.hc.core5.http.io.entity.EntityUtils; import org.apache.hc.core5.http.message.BasicHeader; -import org.junit.After; import org.junit.Before; import org.opensearch.client.Response; import org.opensearch.common.xcontent.XContentHelper; @@ -20,38 +19,25 @@ import com.google.common.collect.ImmutableList; -import lombok.SneakyThrows; - public class SparseEncodingProcessIT extends BaseNeuralSearchIT { private static final String INDEX_NAME = "sparse_encoding_index"; private static final String PIPELINE_NAME = "pipeline-sparse-encoding"; - private String modelId; @Before public void setUp() throws Exception { super.setUp(); - modelId = prepareSparseEncodingModel(); - } - - @After - @SneakyThrows - public void tearDown() { - super.tearDown(); - /* this is required to minimize chance of model not being deployed due to open memory CB, - * this happens in case we leave model from previous test case. We use new model for every test, and old model - * can be undeployed and deleted to free resources after each test case execution. - */ - deleteModel(modelId); - deleteIndex(INDEX_NAME); + updateClusterSettings(); } public void testSparseEncodingProcessor() throws Exception { + String modelId = prepareSparseEncodingModel(); createPipelineProcessor(modelId, PIPELINE_NAME, ProcessorType.SPARSE_ENCODING); createSparseEncodingIndex(); ingestDocument(); assertEquals(1, getDocCount(INDEX_NAME)); + wipeOfTestResources(INDEX_NAME, PIPELINE_NAME, modelId, null); } private void createSparseEncodingIndex() throws Exception { diff --git a/src/test/java/org/opensearch/neuralsearch/processor/TextEmbeddingProcessorIT.java b/src/test/java/org/opensearch/neuralsearch/processor/TextEmbeddingProcessorIT.java index ec6b84601..88aaaba84 100644 --- a/src/test/java/org/opensearch/neuralsearch/processor/TextEmbeddingProcessorIT.java +++ b/src/test/java/org/opensearch/neuralsearch/processor/TextEmbeddingProcessorIT.java @@ -11,7 +11,6 @@ import org.apache.hc.core5.http.HttpHeaders; import org.apache.hc.core5.http.io.entity.EntityUtils; import org.apache.hc.core5.http.message.BasicHeader; -import org.junit.After; import org.junit.Before; import org.opensearch.client.Response; import org.opensearch.common.xcontent.XContentHelper; @@ -20,39 +19,26 @@ import com.google.common.collect.ImmutableList; -import lombok.SneakyThrows; - public class TextEmbeddingProcessorIT extends BaseNeuralSearchIT { private static final String INDEX_NAME = "text_embedding_index"; private static final String PIPELINE_NAME = "pipeline-hybrid"; - private String modelId; @Before public void setUp() throws Exception { super.setUp(); - modelId = uploadTextEmbeddingModel(); - } - - @After - @SneakyThrows - public void tearDown() { - super.tearDown(); - /* this is required to minimize chance of model not being deployed due to open memory CB, - * this happens in case we leave model from previous test case. We use new model for every test, and old model - * can be undeployed and deleted to free resources after each test case execution. - */ - deleteModel(modelId); - deleteIndex(INDEX_NAME); + updateClusterSettings(); } public void testTextEmbeddingProcessor() throws Exception { + String modelId = uploadTextEmbeddingModel(); loadModel(modelId); createPipelineProcessor(modelId, PIPELINE_NAME, ProcessorType.TEXT_EMBEDDING); createTextEmbeddingIndex(); ingestDocument(); assertEquals(1, getDocCount(INDEX_NAME)); + wipeOfTestResources(INDEX_NAME, PIPELINE_NAME, modelId, null); } private String uploadTextEmbeddingModel() throws Exception { diff --git a/src/test/java/org/opensearch/neuralsearch/processor/TextImageEmbeddingProcessorIT.java b/src/test/java/org/opensearch/neuralsearch/processor/TextImageEmbeddingProcessorIT.java index abf4a84e2..149bfdde1 100644 --- a/src/test/java/org/opensearch/neuralsearch/processor/TextImageEmbeddingProcessorIT.java +++ b/src/test/java/org/opensearch/neuralsearch/processor/TextImageEmbeddingProcessorIT.java @@ -11,7 +11,6 @@ import org.apache.hc.core5.http.HttpHeaders; import org.apache.hc.core5.http.io.entity.EntityUtils; import org.apache.hc.core5.http.message.BasicHeader; -import org.junit.After; import org.junit.Before; import org.opensearch.client.Response; import org.opensearch.common.xcontent.XContentHelper; @@ -20,8 +19,6 @@ import com.google.common.collect.ImmutableList; -import lombok.SneakyThrows; - /** * Testing text_and_image_embedding ingest processor. We can only test text in integ tests, none of pre-built models * supports both text and image. @@ -30,36 +27,31 @@ public class TextImageEmbeddingProcessorIT extends BaseNeuralSearchIT { private static final String INDEX_NAME = "text_image_embedding_index"; private static final String PIPELINE_NAME = "ingest-pipeline"; - private String modelId; @Before public void setUp() throws Exception { super.setUp(); - modelId = uploadModel(); - } - - @After - @SneakyThrows - public void tearDown() { - super.tearDown(); - deleteModel(modelId); - deleteIndex(INDEX_NAME); + updateClusterSettings(); } public void testEmbeddingProcessor_whenIngestingDocumentWithSourceMatchingTextMapping_thenSuccessful() throws Exception { + String modelId = uploadModel(); loadModel(modelId); createPipelineProcessor(modelId, PIPELINE_NAME, ProcessorType.TEXT_IMAGE_EMBEDDING); createTextImageEmbeddingIndex(); ingestDocumentWithTextMappedToEmbeddingField(); assertEquals(1, getDocCount(INDEX_NAME)); + wipeOfTestResources(INDEX_NAME, PIPELINE_NAME, modelId, null); } public void testEmbeddingProcessor_whenIngestingDocumentWithSourceWithoutMatchingInMapping_thenSuccessful() throws Exception { + String modelId = uploadModel(); loadModel(modelId); createPipelineProcessor(modelId, PIPELINE_NAME, ProcessorType.TEXT_IMAGE_EMBEDDING); createTextImageEmbeddingIndex(); ingestDocumentWithoutMappedFields(); assertEquals(1, getDocCount(INDEX_NAME)); + wipeOfTestResources(INDEX_NAME, PIPELINE_NAME, modelId, null); } private String uploadModel() throws Exception { diff --git a/src/test/java/org/opensearch/neuralsearch/query/HybridQueryIT.java b/src/test/java/org/opensearch/neuralsearch/query/HybridQueryIT.java index c80e4e933..25ffcd908 100644 --- a/src/test/java/org/opensearch/neuralsearch/query/HybridQueryIT.java +++ b/src/test/java/org/opensearch/neuralsearch/query/HybridQueryIT.java @@ -23,7 +23,6 @@ import java.util.stream.IntStream; import org.apache.lucene.search.join.ScoreMode; -import org.junit.After; import org.junit.Before; import org.opensearch.client.ResponseException; import org.opensearch.index.query.BoolQueryBuilder; @@ -64,26 +63,11 @@ public class HybridQueryIT extends BaseNeuralSearchIT { private final float[] testVector2 = createRandomVector(TEST_DIMENSION); private final float[] testVector3 = createRandomVector(TEST_DIMENSION); private static final String SEARCH_PIPELINE = "phase-results-hybrid-pipeline"; - private String modelId; @Before public void setUp() throws Exception { super.setUp(); updateClusterSettings(); - modelId = prepareModel(); - createSearchPipelineWithResultsPostProcessor(SEARCH_PIPELINE); - } - - @After - @SneakyThrows - public void tearDown() { - super.tearDown(); - deleteSearchPipeline(SEARCH_PIPELINE); - /* this is required to minimize chance of model not being deployed due to open memory CB, - * this happens in case we leave model from previous test case. We use new model for every test, and old model - * can be undeployed and deleted to free resources after each test case execution. - */ - deleteModel(modelId); } @Override @@ -131,7 +115,8 @@ protected boolean preserveClusterUponCompletion() { @SneakyThrows public void testComplexQuery_whenMultipleSubqueries_thenSuccessful() { initializeIndexIfNotExist(TEST_BASIC_VECTOR_DOC_FIELD_INDEX_NAME); - + String modelId = prepareModel(); + createSearchPipelineWithResultsPostProcessor(SEARCH_PIPELINE); TermQueryBuilder termQueryBuilder1 = QueryBuilders.termQuery(TEST_TEXT_FIELD_NAME_1, TEST_QUERY_TEXT3); TermQueryBuilder termQueryBuilder2 = QueryBuilders.termQuery(TEST_TEXT_FIELD_NAME_1, TEST_QUERY_TEXT4); TermQueryBuilder termQueryBuilder3 = QueryBuilders.termQuery(TEST_TEXT_FIELD_NAME_1, TEST_QUERY_TEXT5); @@ -170,7 +155,7 @@ public void testComplexQuery_whenMultipleSubqueries_thenSuccessful() { assertEquals(3, total.get("value")); assertNotNull(total.get("relation")); assertEquals(RELATION_EQUAL_TO, total.get("relation")); - deleteIndex(TEST_BASIC_VECTOR_DOC_FIELD_INDEX_NAME); + wipeOfTestResources(TEST_BASIC_VECTOR_DOC_FIELD_INDEX_NAME, null, modelId, SEARCH_PIPELINE); } /** @@ -202,7 +187,8 @@ public void testComplexQuery_whenMultipleSubqueries_thenSuccessful() { @SneakyThrows public void testComplexQuery_whenMultipleIdenticalSubQueries_thenSuccessful() { initializeIndexIfNotExist(TEST_BASIC_VECTOR_DOC_FIELD_INDEX_NAME); - + String modelId = prepareModel(); + createSearchPipelineWithResultsPostProcessor(SEARCH_PIPELINE); TermQueryBuilder termQueryBuilder1 = QueryBuilders.termQuery(TEST_TEXT_FIELD_NAME_1, TEST_QUERY_TEXT3); TermQueryBuilder termQueryBuilder2 = QueryBuilders.termQuery(TEST_TEXT_FIELD_NAME_1, TEST_QUERY_TEXT4); TermQueryBuilder termQueryBuilder3 = QueryBuilders.termQuery(TEST_TEXT_FIELD_NAME_1, TEST_QUERY_TEXT3); @@ -240,13 +226,14 @@ public void testComplexQuery_whenMultipleIdenticalSubQueries_thenSuccessful() { assertEquals(2, total.get("value")); assertNotNull(total.get("relation")); assertEquals(RELATION_EQUAL_TO, total.get("relation")); - deleteIndex(TEST_BASIC_VECTOR_DOC_FIELD_INDEX_NAME); + wipeOfTestResources(TEST_BASIC_VECTOR_DOC_FIELD_INDEX_NAME, null, modelId, SEARCH_PIPELINE); } @SneakyThrows public void testNoMatchResults_whenOnlyTermSubQueryWithoutMatch_thenEmptyResult() { initializeIndexIfNotExist(TEST_MULTI_DOC_INDEX_NAME); - + String modelId = prepareModel(); + createSearchPipelineWithResultsPostProcessor(SEARCH_PIPELINE); TermQueryBuilder termQueryBuilder = QueryBuilders.termQuery(TEST_TEXT_FIELD_NAME_1, TEST_QUERY_TEXT); TermQueryBuilder termQuery2Builder = QueryBuilders.termQuery(TEST_TEXT_FIELD_NAME_1, TEST_QUERY_TEXT2); HybridQueryBuilder hybridQueryBuilderOnlyTerm = new HybridQueryBuilder(); @@ -270,13 +257,14 @@ public void testNoMatchResults_whenOnlyTermSubQueryWithoutMatch_thenEmptyResult( assertEquals(0, total.get("value")); assertNotNull(total.get("relation")); assertEquals(RELATION_EQUAL_TO, total.get("relation")); - deleteIndex(TEST_MULTI_DOC_INDEX_NAME); + wipeOfTestResources(TEST_MULTI_DOC_INDEX_NAME, null, modelId, SEARCH_PIPELINE); } @SneakyThrows public void testNestedQuery_whenHybridQueryIsWrappedIntoOtherQuery_thenFail() { initializeIndexIfNotExist(TEST_MULTI_DOC_INDEX_NAME_ONE_SHARD); - + String modelId = prepareModel(); + createSearchPipelineWithResultsPostProcessor(SEARCH_PIPELINE); MatchQueryBuilder matchQueryBuilder = QueryBuilders.matchQuery(TEST_TEXT_FIELD_NAME_1, TEST_QUERY_TEXT3); MatchQueryBuilder matchQuery2Builder = QueryBuilders.matchQuery(TEST_TEXT_FIELD_NAME_1, TEST_QUERY_TEXT4); HybridQueryBuilder hybridQueryBuilderOnlyTerm = new HybridQueryBuilder(); @@ -318,13 +306,14 @@ public void testNestedQuery_whenHybridQueryIsWrappedIntoOtherQuery_thenFail() { containsString("illegal_argument_exception") ) ); - deleteIndex(TEST_MULTI_DOC_INDEX_NAME_ONE_SHARD); + wipeOfTestResources(TEST_MULTI_DOC_INDEX_NAME_ONE_SHARD, null, modelId, SEARCH_PIPELINE); } @SneakyThrows public void testIndexWithNestedFields_whenHybridQuery_thenSuccess() { initializeIndexIfNotExist(TEST_MULTI_DOC_INDEX_WITH_NESTED_TYPE_NAME_ONE_SHARD); - + String modelId = prepareModel(); + createSearchPipelineWithResultsPostProcessor(SEARCH_PIPELINE); TermQueryBuilder termQueryBuilder = QueryBuilders.termQuery(TEST_TEXT_FIELD_NAME_1, TEST_QUERY_TEXT3); TermQueryBuilder termQuery2Builder = QueryBuilders.termQuery(TEST_TEXT_FIELD_NAME_1, TEST_QUERY_TEXT2); HybridQueryBuilder hybridQueryBuilderOnlyTerm = new HybridQueryBuilder(); @@ -348,13 +337,14 @@ public void testIndexWithNestedFields_whenHybridQuery_thenSuccess() { assertEquals(1, total.get("value")); assertNotNull(total.get("relation")); assertEquals(RELATION_EQUAL_TO, total.get("relation")); - deleteIndex(TEST_MULTI_DOC_INDEX_WITH_NESTED_TYPE_NAME_ONE_SHARD); + wipeOfTestResources(TEST_MULTI_DOC_INDEX_WITH_NESTED_TYPE_NAME_ONE_SHARD, null, modelId, SEARCH_PIPELINE); } @SneakyThrows public void testIndexWithNestedFields_whenHybridQueryIncludesNested_thenSuccess() { initializeIndexIfNotExist(TEST_MULTI_DOC_INDEX_WITH_NESTED_TYPE_NAME_ONE_SHARD); - + String modelId = prepareModel(); + createSearchPipelineWithResultsPostProcessor(SEARCH_PIPELINE); TermQueryBuilder termQueryBuilder = QueryBuilders.termQuery(TEST_TEXT_FIELD_NAME_1, TEST_QUERY_TEXT); NestedQueryBuilder nestedQueryBuilder = QueryBuilders.nestedQuery( TEST_NESTED_TYPE_FIELD_NAME_1, @@ -382,7 +372,7 @@ public void testIndexWithNestedFields_whenHybridQueryIncludesNested_thenSuccess( assertEquals(1, total.get("value")); assertNotNull(total.get("relation")); assertEquals(RELATION_EQUAL_TO, total.get("relation")); - deleteIndex(TEST_MULTI_DOC_INDEX_WITH_NESTED_TYPE_NAME_ONE_SHARD); + wipeOfTestResources(TEST_MULTI_DOC_INDEX_WITH_NESTED_TYPE_NAME_ONE_SHARD, null, modelId, SEARCH_PIPELINE); } @SneakyThrows diff --git a/src/test/java/org/opensearch/neuralsearch/query/NeuralQueryIT.java b/src/test/java/org/opensearch/neuralsearch/query/NeuralQueryIT.java index 18902dca8..15c970797 100644 --- a/src/test/java/org/opensearch/neuralsearch/query/NeuralQueryIT.java +++ b/src/test/java/org/opensearch/neuralsearch/query/NeuralQueryIT.java @@ -14,7 +14,6 @@ import java.util.List; import java.util.Map; -import org.junit.After; import org.junit.Before; import org.opensearch.index.query.BoolQueryBuilder; import org.opensearch.index.query.MatchAllQueryBuilder; @@ -38,24 +37,11 @@ public class NeuralQueryIT extends BaseNeuralSearchIT { private static final String TEST_TEXT_FIELD_NAME_1 = "test-text-field"; private static final String TEST_KNN_VECTOR_FIELD_NAME_NESTED = "nested.knn.field"; private final float[] testVector = createRandomVector(TEST_DIMENSION); - private String modelId; @Before public void setUp() throws Exception { super.setUp(); updateClusterSettings(); - modelId = prepareModel(); - } - - @After - @SneakyThrows - public void tearDown() { - super.tearDown(); - /* this is required to minimize chance of model not being deployed due to open memory CB, - * this happens in case we leave model from previous test case. We use new model for every test, and old model - * can be undeployed and deleted to free resources after each test case execution. - */ - deleteModel(modelId); } /** @@ -75,6 +61,7 @@ public void tearDown() { @SneakyThrows public void testBasicQuery() { initializeIndexIfNotExist(TEST_BASIC_INDEX_NAME); + String modelId = prepareModel(); NeuralQueryBuilder neuralQueryBuilder = new NeuralQueryBuilder( TEST_KNN_VECTOR_FIELD_NAME_1, TEST_QUERY_TEXT, @@ -90,7 +77,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")), DELTA_FOR_SCORE_ASSERTION); - deleteIndex(TEST_BASIC_INDEX_NAME); + wipeOfTestResources(TEST_BASIC_INDEX_NAME, null, modelId, null); } /** @@ -111,6 +98,7 @@ public void testBasicQuery() { @SneakyThrows public void testBoostQuery() { initializeIndexIfNotExist(TEST_BASIC_INDEX_NAME); + String modelId = prepareModel(); NeuralQueryBuilder neuralQueryBuilder = new NeuralQueryBuilder( TEST_KNN_VECTOR_FIELD_NAME_1, TEST_QUERY_TEXT, @@ -129,7 +117,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")), DELTA_FOR_SCORE_ASSERTION); - deleteIndex(TEST_BASIC_INDEX_NAME); + wipeOfTestResources(TEST_BASIC_INDEX_NAME, null, modelId, null); } /** @@ -155,6 +143,7 @@ public void testBoostQuery() { @SneakyThrows public void testRescoreQuery() { initializeIndexIfNotExist(TEST_BASIC_INDEX_NAME); + String modelId = prepareModel(); MatchAllQueryBuilder matchAllQueryBuilder = new MatchAllQueryBuilder(); NeuralQueryBuilder rescoreNeuralQueryBuilder = new NeuralQueryBuilder( TEST_KNN_VECTOR_FIELD_NAME_1, @@ -172,7 +161,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")), DELTA_FOR_SCORE_ASSERTION); - deleteIndex(TEST_BASIC_INDEX_NAME); + wipeOfTestResources(TEST_BASIC_INDEX_NAME, null, modelId, null); } /** @@ -203,6 +192,7 @@ public void testRescoreQuery() { @SneakyThrows public void testBooleanQuery_withMultipleNeuralQueries() { initializeIndexIfNotExist(TEST_MULTI_VECTOR_FIELD_INDEX_NAME); + String modelId = prepareModel(); BoolQueryBuilder boolQueryBuilder = new BoolQueryBuilder(); NeuralQueryBuilder neuralQueryBuilder1 = new NeuralQueryBuilder( @@ -232,7 +222,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")), DELTA_FOR_SCORE_ASSERTION); - deleteIndex(TEST_MULTI_VECTOR_FIELD_INDEX_NAME); + wipeOfTestResources(TEST_MULTI_VECTOR_FIELD_INDEX_NAME, null, modelId, null); } /** @@ -261,6 +251,7 @@ public void testBooleanQuery_withMultipleNeuralQueries() { @SneakyThrows public void testBooleanQuery_withNeuralAndBM25Queries() { initializeIndexIfNotExist(TEST_TEXT_AND_VECTOR_FIELD_INDEX_NAME); + String modelId = prepareModel(); BoolQueryBuilder boolQueryBuilder = new BoolQueryBuilder(); NeuralQueryBuilder neuralQueryBuilder = new NeuralQueryBuilder( @@ -283,7 +274,7 @@ public void testBooleanQuery_withNeuralAndBM25Queries() { assertEquals("1", firstInnerHit.get("_id")); float minExpectedScore = computeExpectedScore(modelId, testVector, TEST_SPACE_TYPE, TEST_QUERY_TEXT); assertTrue(minExpectedScore < objectToFloat(firstInnerHit.get("_score"))); - deleteIndex(TEST_TEXT_AND_VECTOR_FIELD_INDEX_NAME); + wipeOfTestResources(TEST_TEXT_AND_VECTOR_FIELD_INDEX_NAME, null, modelId, null); } /** @@ -307,7 +298,7 @@ public void testBooleanQuery_withNeuralAndBM25Queries() { @SneakyThrows public void testNestedQuery() { initializeIndexIfNotExist(TEST_NESTED_INDEX_NAME); - + String modelId = prepareModel(); NeuralQueryBuilder neuralQueryBuilder = new NeuralQueryBuilder( TEST_KNN_VECTOR_FIELD_NAME_NESTED, TEST_QUERY_TEXT, @@ -324,7 +315,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")), DELTA_FOR_SCORE_ASSERTION); - deleteIndex(TEST_NESTED_INDEX_NAME); + wipeOfTestResources(TEST_NESTED_INDEX_NAME, null, modelId, null); } /** @@ -351,6 +342,7 @@ public void testNestedQuery() { @SneakyThrows public void testFilterQuery() { initializeIndexIfNotExist(TEST_MULTI_DOC_INDEX_NAME); + String modelId = prepareModel(); NeuralQueryBuilder neuralQueryBuilder = new NeuralQueryBuilder( TEST_KNN_VECTOR_FIELD_NAME_1, TEST_QUERY_TEXT, @@ -366,7 +358,7 @@ public void testFilterQuery() { assertEquals("3", firstInnerHit.get("_id")); float expectedScore = computeExpectedScore(modelId, testVector, TEST_SPACE_TYPE, TEST_QUERY_TEXT); assertEquals(expectedScore, objectToFloat(firstInnerHit.get("_score")), DELTA_FOR_SCORE_ASSERTION); - deleteIndex(TEST_MULTI_DOC_INDEX_NAME); + wipeOfTestResources(TEST_MULTI_DOC_INDEX_NAME, null, modelId, null); } /** @@ -387,6 +379,7 @@ public void testFilterQuery() { @SneakyThrows public void testMultimodalQuery() { initializeIndexIfNotExist(TEST_BASIC_INDEX_NAME); + String modelId = prepareModel(); NeuralQueryBuilder neuralQueryBuilder = new NeuralQueryBuilder( TEST_KNN_VECTOR_FIELD_NAME_1, TEST_QUERY_TEXT, @@ -402,7 +395,7 @@ 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")), DELTA_FOR_SCORE_ASSERTION); - deleteIndex(TEST_BASIC_INDEX_NAME); + wipeOfTestResources(TEST_BASIC_INDEX_NAME, null, modelId, null); } @SneakyThrows diff --git a/src/test/java/org/opensearch/neuralsearch/query/NeuralSparseQueryIT.java b/src/test/java/org/opensearch/neuralsearch/query/NeuralSparseQueryIT.java index 25d80b261..0e403d0d9 100644 --- a/src/test/java/org/opensearch/neuralsearch/query/NeuralSparseQueryIT.java +++ b/src/test/java/org/opensearch/neuralsearch/query/NeuralSparseQueryIT.java @@ -10,7 +10,6 @@ import java.util.List; import java.util.Map; -import org.junit.After; import org.junit.Before; import org.opensearch.client.ResponseException; import org.opensearch.index.query.BoolQueryBuilder; @@ -35,20 +34,11 @@ public class NeuralSparseQueryIT extends BaseNeuralSearchIT { private static final Float DELTA = 1e-5f; private final Map testRankFeaturesDoc = TestUtils.createRandomTokenWeightMap(TEST_TOKENS); - private String modelId; @Before public void setUp() throws Exception { super.setUp(); updateClusterSettings(); - modelId = prepareSparseEncodingModel(); - } - - @After - @SneakyThrows - public void tearDown() { - super.tearDown(); - deleteModel(modelId); } /** @@ -67,6 +57,7 @@ public void tearDown() { @SneakyThrows public void testBasicQueryUsingQueryText() { initializeIndexIfNotExist(TEST_BASIC_INDEX_NAME); + String modelId = prepareSparseEncodingModel(); NeuralSparseQueryBuilder sparseEncodingQueryBuilder = new NeuralSparseQueryBuilder().fieldName(TEST_NEURAL_SPARSE_FIELD_NAME_1) .queryText(TEST_QUERY_TEXT) .modelId(modelId); @@ -76,7 +67,7 @@ public void testBasicQueryUsingQueryText() { assertEquals("1", firstInnerHit.get("_id")); float expectedScore = computeExpectedScore(modelId, testRankFeaturesDoc, TEST_QUERY_TEXT); assertEquals(expectedScore, objectToFloat(firstInnerHit.get("_score")), DELTA); - deleteIndex(TEST_BASIC_INDEX_NAME); + wipeOfTestResources(TEST_BASIC_INDEX_NAME, null, modelId, null); } /** @@ -96,6 +87,7 @@ public void testBasicQueryUsingQueryText() { @SneakyThrows public void testBoostQuery() { initializeIndexIfNotExist(TEST_BASIC_INDEX_NAME); + String modelId = prepareSparseEncodingModel(); NeuralSparseQueryBuilder sparseEncodingQueryBuilder = new NeuralSparseQueryBuilder().fieldName(TEST_NEURAL_SPARSE_FIELD_NAME_1) .queryText(TEST_QUERY_TEXT) .modelId(modelId) @@ -106,7 +98,7 @@ public void testBoostQuery() { assertEquals("1", firstInnerHit.get("_id")); float expectedScore = 2 * computeExpectedScore(modelId, testRankFeaturesDoc, TEST_QUERY_TEXT); assertEquals(expectedScore, objectToFloat(firstInnerHit.get("_score")), DELTA); - deleteIndex(TEST_BASIC_INDEX_NAME); + wipeOfTestResources(TEST_BASIC_INDEX_NAME, null, modelId, null); } /** @@ -132,6 +124,7 @@ public void testBoostQuery() { @SneakyThrows public void testRescoreQuery() { initializeIndexIfNotExist(TEST_BASIC_INDEX_NAME); + String modelId = prepareSparseEncodingModel(); MatchAllQueryBuilder matchAllQueryBuilder = new MatchAllQueryBuilder(); NeuralSparseQueryBuilder sparseEncodingQueryBuilder = new NeuralSparseQueryBuilder().fieldName(TEST_NEURAL_SPARSE_FIELD_NAME_1) .queryText(TEST_QUERY_TEXT) @@ -142,7 +135,7 @@ public void testRescoreQuery() { assertEquals("1", firstInnerHit.get("_id")); float expectedScore = computeExpectedScore(modelId, testRankFeaturesDoc, TEST_QUERY_TEXT); assertEquals(expectedScore, objectToFloat(firstInnerHit.get("_score")), DELTA); - deleteIndex(TEST_BASIC_INDEX_NAME); + wipeOfTestResources(TEST_BASIC_INDEX_NAME, null, modelId, null); } /** @@ -171,6 +164,7 @@ public void testRescoreQuery() { @SneakyThrows public void testBooleanQuery_withMultipleSparseEncodingQueries() { initializeIndexIfNotExist(TEST_MULTI_NEURAL_SPARSE_FIELD_INDEX_NAME); + String modelId = prepareSparseEncodingModel(); BoolQueryBuilder boolQueryBuilder = new BoolQueryBuilder(); NeuralSparseQueryBuilder sparseEncodingQueryBuilder1 = new NeuralSparseQueryBuilder().fieldName(TEST_NEURAL_SPARSE_FIELD_NAME_1) @@ -188,7 +182,7 @@ public void testBooleanQuery_withMultipleSparseEncodingQueries() { assertEquals("1", firstInnerHit.get("_id")); float expectedScore = 2 * computeExpectedScore(modelId, testRankFeaturesDoc, TEST_QUERY_TEXT); assertEquals(expectedScore, objectToFloat(firstInnerHit.get("_score")), DELTA); - deleteIndex(TEST_MULTI_NEURAL_SPARSE_FIELD_INDEX_NAME); + wipeOfTestResources(TEST_MULTI_NEURAL_SPARSE_FIELD_INDEX_NAME, null, modelId, null); } /** @@ -217,6 +211,7 @@ public void testBooleanQuery_withMultipleSparseEncodingQueries() { @SneakyThrows public void testBooleanQuery_withSparseEncodingAndBM25Queries() { initializeIndexIfNotExist(TEST_TEXT_AND_NEURAL_SPARSE_FIELD_INDEX_NAME); + String modelId = prepareSparseEncodingModel(); BoolQueryBuilder boolQueryBuilder = new BoolQueryBuilder(); NeuralSparseQueryBuilder sparseEncodingQueryBuilder = new NeuralSparseQueryBuilder().fieldName(TEST_NEURAL_SPARSE_FIELD_NAME_1) @@ -231,18 +226,19 @@ public void testBooleanQuery_withSparseEncodingAndBM25Queries() { assertEquals("1", firstInnerHit.get("_id")); float minExpectedScore = computeExpectedScore(modelId, testRankFeaturesDoc, TEST_QUERY_TEXT); assertTrue(minExpectedScore < objectToFloat(firstInnerHit.get("_score"))); - deleteIndex(TEST_TEXT_AND_NEURAL_SPARSE_FIELD_INDEX_NAME); + wipeOfTestResources(TEST_TEXT_AND_NEURAL_SPARSE_FIELD_INDEX_NAME, null, modelId, null); } @SneakyThrows public void testBasicQueryUsingQueryText_whenQueryWrongFieldType_thenFail() { initializeIndexIfNotExist(TEST_TEXT_AND_NEURAL_SPARSE_FIELD_INDEX_NAME); - + String modelId = prepareSparseEncodingModel(); NeuralSparseQueryBuilder sparseEncodingQueryBuilder = new NeuralSparseQueryBuilder().fieldName(TEST_TEXT_FIELD_NAME_1) .queryText(TEST_QUERY_TEXT) .modelId(modelId); expectThrows(ResponseException.class, () -> search(TEST_TEXT_AND_NEURAL_SPARSE_FIELD_INDEX_NAME, sparseEncodingQueryBuilder, 1)); + wipeOfTestResources(TEST_TEXT_AND_NEURAL_SPARSE_FIELD_INDEX_NAME, null, modelId, null); } @SneakyThrows