Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BWC tests for Multimodal Search, Hybrid Search and Neural Sparse Search #533

Merged
merged 85 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from 83 commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
6a570bd
Reformatting test package
vibrantvarun Dec 7, 2023
b5a0fe4
rebasing
vibrantvarun Dec 7, 2023
724bd36
Initial commit of BWC Test
vibrantvarun Dec 7, 2023
a9357f2
Text Search
vibrantvarun Dec 19, 2023
8c0f22d
Fixing bug
vibrantvarun Dec 19, 2023
26eb401
Text Search bug fix
vibrantvarun Dec 20, 2023
7926189
Adding windows platform in bwc
vibrantvarun Dec 20, 2023
1f880dd
Adding windows platform in bwc
vibrantvarun Dec 20, 2023
a92e37c
Rolling Upgrade tests
vibrantvarun Dec 20, 2023
723fc13
Bux Fix in rolling upgrade
vibrantvarun Dec 20, 2023
975eaea
Bug Fix Rolling Upgrade
vibrantvarun Dec 21, 2023
5482a4e
Fixing Flaky tests
vibrantvarun Dec 21, 2023
38bd10b
Updating BWC version to latest
vibrantvarun Dec 21, 2023
b794610
Fixing bwc test
vibrantvarun Dec 21, 2023
74d9aef
Semantic Search
vibrantvarun Dec 26, 2023
ba17401
Bug Fix
vibrantvarun Dec 26, 2023
eccaf2a
Debugging
vibrantvarun Dec 26, 2023
e400e06
Bug Fix
vibrantvarun Dec 26, 2023
038cd1a
Increase memory in nodes
vibrantvarun Dec 26, 2023
6bb2dd3
Removing extra logging
vibrantvarun Dec 27, 2023
a5d17e1
Cleaning up
vibrantvarun Dec 27, 2023
f84bb56
Updating Pipeline Configuration
vibrantvarun Dec 27, 2023
37730b6
Initial commit
vibrantvarun Dec 27, 2023
d6d7f9b
Remove KNN delete models
vibrantvarun Dec 27, 2023
20ec55f
Remove unecessary KNN code
vibrantvarun Dec 27, 2023
4a7ea91
Addressing comments of naveen
vibrantvarun Dec 27, 2023
563caf8
Addressing comments of naveen
vibrantvarun Dec 27, 2023
88823b3
Addressing comments of Naveen
vibrantvarun Dec 27, 2023
de02df2
Addressing martin comments
vibrantvarun Dec 28, 2023
d7c6151
Addressing comments of martin
vibrantvarun Dec 28, 2023
820917b
Apply formatting.xml in all lines
vibrantvarun Dec 28, 2023
69a41bc
Removing extra spacess from formatting.gradle
vibrantvarun Dec 28, 2023
2a71941
Addressing martin comment
vibrantvarun Dec 28, 2023
3cd927b
Addressing Jack comments
vibrantvarun Dec 28, 2023
3a3d175
Addressing Jack comments
vibrantvarun Dec 29, 2023
24dab4f
Merge branch 'main' into formatting-1
vibrantvarun Dec 29, 2023
cba8193
Addressing Jack's comments
vibrantvarun Dec 29, 2023
8721079
Fixing Test cases
vibrantvarun Dec 29, 2023
e371d58
Addressing comments of Navneet
vibrantvarun Jan 2, 2024
2dcb631
Addressing comments of Navneet
vibrantvarun Jan 2, 2024
2ace98f
Addressing comments of Navneet
vibrantvarun Jan 2, 2024
ef84f99
Addressing comments of Navneet
vibrantvarun Jan 2, 2024
b756f86
Merge branch 'formatting-1' into formatting-2
vibrantvarun Jan 2, 2024
c9685b6
Adding mutimodel IT
vibrantvarun Jan 2, 2024
1ebe6a4
Removing extra parameter from createPipelineProcessor
vibrantvarun Jan 2, 2024
2bfae9a
Merge branch 'formatting-1' into formatting-2
vibrantvarun Jan 2, 2024
777e344
Multimodal tests
vibrantvarun Jan 2, 2024
7b3498e
Fixing bug
vibrantvarun Jan 2, 2024
7f3e9e4
Increasing number of shards
vibrantvarun Jan 2, 2024
136bb81
Bug fix of load model id
vibrantvarun Jan 2, 2024
9540c8f
Merge branch 'formatting-1' into formatting-2
vibrantvarun Jan 2, 2024
af6750d
Rolling upgrade multimodel tests
vibrantvarun Jan 2, 2024
a8a8dc0
Multimodal rolling upgrade tests
vibrantvarun Jan 2, 2024
0ab205e
Adding loadModel Id in upgraded test case
vibrantvarun Jan 2, 2024
e5c270e
Hybrid Search initial commit
vibrantvarun Jan 2, 2024
622a8dc
Rebasing
vibrantvarun Jan 5, 2024
cd2b4f5
Hybrid Search
vibrantvarun Jan 7, 2024
da217f4
Merge branch 'main' into formatting-2
vibrantvarun Jan 7, 2024
2d5cc38
Rolling upgrade for Hybrid Search Tests
vibrantvarun Jan 8, 2024
b174878
Uncommenting Multimodal Search Tests
vibrantvarun Jan 8, 2024
1e7c93c
Fixing Test Cases
vibrantvarun Jan 8, 2024
be567db
Fixing Test Cases
vibrantvarun Jan 8, 2024
8ec2ba8
modifying check in hybrid search
vibrantvarun Jan 8, 2024
98a9805
Neural Sparse Search BWC tests
vibrantvarun Jan 8, 2024
26485d7
Addressing Martin Comments
vibrantvarun Jan 9, 2024
781551c
Modifying Neural Sparse Tests
vibrantvarun Jan 10, 2024
494d972
Fixing test Cases
vibrantvarun Jan 10, 2024
f78109c
Adding extra check to ensure model gets undeployed and then gets deleted
vibrantvarun Jan 12, 2024
9f47f04
Bux fix for issue 433
vibrantvarun Jan 12, 2024
6804861
Removing flaky test fix
vibrantvarun Jan 12, 2024
27d9bbc
Merge branch 'main' into formatting-2
vibrantvarun Jan 12, 2024
f9ffc14
Addressing martin comments
vibrantvarun Jan 16, 2024
bccc681
Addressing Martin Comments
vibrantvarun Jan 16, 2024
916d913
Merge branch 'main' into formatting-2
vibrantvarun Jan 19, 2024
bd8a3d2
Merge branch 'main' into formatting-2
vibrantvarun Jan 24, 2024
27a20b2
Refactoring BaseSparseEncodingIT and enabling BWC tests
vibrantvarun Jan 24, 2024
df88c8e
Rebasing
vibrantvarun Jan 24, 2024
d0d8494
Fixing Bug
vibrantvarun Jan 24, 2024
dccbd74
Addressing comments of martin
vibrantvarun Jan 24, 2024
19812e5
Increasing attempts of timeout
vibrantvarun Jan 24, 2024
8cb9f64
Add pollformodelstate in load model
vibrantvarun Jan 24, 2024
7bccb42
Fixing Build
vibrantvarun Jan 24, 2024
98050a1
Addressing martin and hemmin comments
vibrantvarun Jan 25, 2024
786b150
Addressing heemin's comment
vibrantvarun Jan 25, 2024
85bfcc2
Add Changelog
vibrantvarun Jan 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ jobs:
- name: Run NeuralSearch Restart-Upgrade BWC Tests from BWCVersion-${{ matrix.bwc_version }} to OpenSearch Version-${{ matrix.opensearch_version }} on ${{matrix.os}}
run: |
echo "Running restart-upgrade backwards compatibility tests ..."
# Disabling BWC tests due to ongoing build failure. https://github.com/opensearch-project/neural-search/issues/536
# ./gradlew :qa:restart-upgrade:testAgainstNewCluster -D'tests.bwc.version=${{ matrix.bwc_version }}'
./gradlew :qa:restart-upgrade:testAgainstNewCluster -D'tests.bwc.version=${{ matrix.bwc_version }}'

Rolling-Upgrade-BWCTests-NeuralSearch:
strategy:
matrix:
java: [ 11, 17, 21 ]
# Restricting java 21 to 21.0.1 due to ongoing bug in JDK 21.0.2 https://bugs.openjdk.org/browse/JDK-8323659. Once the fix https://github.com/opensearch-project/OpenSearch/pull/11968 get merged this change will be reverted.
java: [ 11, 17, 21.0.1 ]
os: [ubuntu-latest,windows-latest]
bwc_version: [ "2.12.0-SNAPSHOT" ]
opensearch_version: [ "3.0.0-SNAPSHOT" ]
Expand All @@ -64,5 +64,4 @@ jobs:
- name: Run NeuralSearch Rolling-Upgrade BWC Tests from BWCVersion-${{ matrix.bwc_version }} to OpenSearch Version-${{ matrix.opensearch_version }} on ${{matrix.os}}
run: |
echo "Running rolling-upgrade backwards compatibility tests ..."
# Disabling BWC tests due to ongoing build failure. https://github.com/opensearch-project/neural-search/issues/536
# ./gradlew :qa:rolling-upgrade:testRollingUpgrade -D'tests.bwc.version=${{ matrix.bwc_version }}'
./gradlew :qa:rolling-upgrade:testRollingUpgrade -D'tests.bwc.version=${{ matrix.bwc_version }}'
18 changes: 18 additions & 0 deletions qa/restart-upgrade/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ task testAgainstOldCluster(type: StandaloneRestIntegTestTask) {
systemProperty 'tests.skip_delete_model_index', 'true'
systemProperty 'tests.plugin_bwc_version', neural_search_bwc_version

//Excluding MultiModalSearchIT, HybridSearchIT, NeuralSparseSearchIT tests from neural search version 2.9 and 2.10 because these features were released in 2.11 version.
if (neural_search_bwc_version.startsWith("2.9") || neural_search_bwc_version.startsWith("2.10")){
vibrantvarun marked this conversation as resolved.
Show resolved Hide resolved
filter {
excludeTestsMatching "org.opensearch.neuralsearch.bwc.MultiModalSearchIT.*"
excludeTestsMatching "org.opensearch.neuralsearch.bwc.HybridSearchIT.*"
excludeTestsMatching "org.opensearch.neuralsearch.bwc.NeuralSparseSearchIT.*"
}
}

nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}".allHttpSocketURI.join(",")}")
nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}".getName()}")
systemProperty 'tests.security.manager', 'false'
Expand All @@ -53,6 +62,15 @@ task testAgainstNewCluster(type: StandaloneRestIntegTestTask) {
systemProperty 'tests.is_old_cluster', 'false'
systemProperty 'tests.plugin_bwc_version', neural_search_bwc_version

//Excluding MultiModalSearchIT, HybridSearchIT, NeuralSparseSearchIT tests from neural search version 2.9 and 2.10 because these features were released in 2.11 version.
if (neural_search_bwc_version.startsWith("2.9") || neural_search_bwc_version.startsWith("2.10")){
filter {
excludeTestsMatching "org.opensearch.neuralsearch.bwc.MultiModalSearchIT.*"
excludeTestsMatching "org.opensearch.neuralsearch.bwc.HybridSearchIT.*"
excludeTestsMatching "org.opensearch.neuralsearch.bwc.NeuralSparseSearchIT.*"
}
}

nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}".allHttpSocketURI.join(",")}")
nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}".getName()}")
systemProperty 'tests.security.manager', 'false'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@
*/
package org.opensearch.neuralsearch.bwc;

import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Locale;
import java.util.Optional;
import org.junit.Before;
import org.opensearch.common.settings.Settings;
import org.opensearch.neuralsearch.BaseNeuralSearchIT;
import static org.opensearch.neuralsearch.TestUtils.NEURAL_SEARCH_BWC_PREFIX;
import static org.opensearch.neuralsearch.TestUtils.CLIENT_TIMEOUT_VALUE;
import static org.opensearch.neuralsearch.TestUtils.RESTART_UPGRADE_OLD_CLUSTER;
import static org.opensearch.neuralsearch.TestUtils.BWC_VERSION;
import static org.opensearch.neuralsearch.TestUtils.NEURAL_SEARCH_BWC_PREFIX;
import static org.opensearch.neuralsearch.TestUtils.generateModelId;
import org.opensearch.test.rest.OpenSearchRestTestCase;

public abstract class AbstractRestartUpgradeRestTestCase extends BaseNeuralSearchIT {
Expand Down Expand Up @@ -57,4 +60,43 @@ protected static final boolean isRunningAgainstOldCluster() {
protected final Optional<String> getBWCVersion() {
return Optional.ofNullable(System.getProperty(BWC_VERSION, null));
}

protected String uploadTextEmbeddingModel() throws Exception {
String requestBody = Files.readString(Path.of(classLoader.getResource("processor/UploadModelRequestBody.json").toURI()));
return registerModelGroupAndGetModelId(requestBody);
}

protected String registerModelGroupAndGetModelId(final String requestBody) throws Exception {
String modelGroupRegisterRequestBody = Files.readString(
Path.of(classLoader.getResource("processor/CreateModelGroupRequestBody.json").toURI())
);
String modelGroupId = registerModelGroup(String.format(LOCALE, modelGroupRegisterRequestBody, generateModelId()));
return uploadModel(String.format(LOCALE, requestBody, modelGroupId));
}

protected void createPipelineProcessor(final String modelId, final String pipelineName) throws Exception {
String requestBody = Files.readString(Path.of(classLoader.getResource("processor/PipelineConfiguration.json").toURI()));
createPipelineProcessor(requestBody, pipelineName, modelId);
}

protected String uploadSparseEncodingModel() throws Exception {
String requestBody = Files.readString(
Path.of(classLoader.getResource("processor/UploadSparseEncodingModelRequestBody.json").toURI())
);
return registerModelGroupAndGetModelId(requestBody);
}

protected void createPipelineForTextImageProcessor(final String modelId, final String pipelineName) throws Exception {
String requestBody = Files.readString(
Path.of(classLoader.getResource("processor/PipelineForTextImageProcessorConfiguration.json").toURI())
);
createPipelineProcessor(requestBody, pipelineName, modelId);
}

protected void createPipelineForSparseEncodingProcessor(final String modelId, final String pipelineName) throws Exception {
String requestBody = Files.readString(
Path.of(classLoader.getResource("processor/PipelineForSparseEncodingProcessorConfiguration.json").toURI())
);
createPipelineProcessor(requestBody, pipelineName, modelId);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/
package org.opensearch.neuralsearch.bwc;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import org.opensearch.index.query.MatchQueryBuilder;
import static org.opensearch.neuralsearch.TestUtils.getModelId;
import static org.opensearch.neuralsearch.TestUtils.NODES_BWC_CLUSTER;
import static org.opensearch.neuralsearch.TestUtils.PARAM_NAME_WEIGHTS;
import static org.opensearch.neuralsearch.TestUtils.TEXT_EMBEDDING_PROCESSOR;
import static org.opensearch.neuralsearch.TestUtils.DEFAULT_NORMALIZATION_METHOD;
import static org.opensearch.neuralsearch.TestUtils.DEFAULT_COMBINATION_METHOD;
import org.opensearch.neuralsearch.query.HybridQueryBuilder;
import org.opensearch.neuralsearch.query.NeuralQueryBuilder;

public class HybridSearchIT extends AbstractRestartUpgradeRestTestCase {
private static final String PIPELINE_NAME = "nlp-hybrid-pipeline";
private static final String PIPELINE1_NAME = "nlp-hybrid-1-pipeline";
private static final String SEARCH_PIPELINE_NAME = "nlp-search-pipeline";
private static final String SEARCH_PIPELINE1_NAME = "nlp-search-1-pipeline";
private static final String TEST_FIELD = "passage_text";
private static final String TEXT_1 = "Hello world";
private static final String TEXT_2 = "Hi planet";
private static final String TEXT_3 = "Hi earth";
private static final String TEXT_4 = "Hi amazon";
private static final String TEXT_5 = "Hi mars";
private static final String TEXT_6 = "Hi opensearch";
private static final String QUERY = "Hi world";

// Test restart-upgrade normalization processor when index with multiple shards
// Create Text Embedding Processor, Ingestion Pipeline, add document and search pipeline with normalization processor
// Validate process , pipeline and document count in restart-upgrade scenario
public void testNormalizationProcessor_whenIndexWithMultipleShards_E2EFlow() throws Exception {
vibrantvarun marked this conversation as resolved.
Show resolved Hide resolved
vibrantvarun marked this conversation as resolved.
Show resolved Hide resolved
waitForClusterHealthGreen(NODES_BWC_CLUSTER);
if (isRunningAgainstOldCluster()) {
String modelId = uploadTextEmbeddingModel();
loadModel(modelId);
vibrantvarun marked this conversation as resolved.
Show resolved Hide resolved
createPipelineProcessor(modelId, PIPELINE_NAME);
createIndexWithConfiguration(
vibrantvarun marked this conversation as resolved.
Show resolved Hide resolved
getIndexNameForTest(),
Files.readString(Path.of(classLoader.getResource("processor/IndexMappingMultipleShard.json").toURI())),
PIPELINE_NAME
);
addDocuments(getIndexNameForTest(), true);
createSearchPipeline(SEARCH_PIPELINE_NAME);
} else {
String modelId = null;
try {
modelId = getModelId(getIngestionPipeline(PIPELINE_NAME), TEXT_EMBEDDING_PROCESSOR);
loadModel(modelId);
addDocuments(getIndexNameForTest(), false);
validateTestIndex(modelId, getIndexNameForTest(), SEARCH_PIPELINE_NAME);
} finally {
wipeOfTestResources(getIndexNameForTest(), PIPELINE_NAME, modelId, SEARCH_PIPELINE_NAME);
}
}
}

// Test restart-upgrade normalization processor when index with single shard
// Create Text Embedding Processor, Ingestion Pipeline, add document and search pipeline with normalization processor
// Validate process , pipeline and document count in restart-upgrade scenario
public void testNormalizationProcessor_whenIndexWithSingleShard_E2EFlow() throws Exception {
vibrantvarun marked this conversation as resolved.
Show resolved Hide resolved
waitForClusterHealthGreen(NODES_BWC_CLUSTER);
if (isRunningAgainstOldCluster()) {
String modelId = uploadTextEmbeddingModel();
loadModel(modelId);
createPipelineProcessor(modelId, PIPELINE1_NAME);
createIndexWithConfiguration(
getIndexNameForTest(),
Files.readString(Path.of(classLoader.getResource("processor/IndexMappingSingleShard.json").toURI())),
PIPELINE1_NAME
);
addDocuments(getIndexNameForTest(), true);
createSearchPipeline(SEARCH_PIPELINE1_NAME);
} else {
String modelId = null;
try {
modelId = getModelId(getIngestionPipeline(PIPELINE1_NAME), TEXT_EMBEDDING_PROCESSOR);
loadModel(modelId);
addDocuments(getIndexNameForTest(), false);
validateTestIndex(modelId, getIndexNameForTest(), SEARCH_PIPELINE1_NAME);
} finally {
wipeOfTestResources(getIndexNameForTest(), PIPELINE1_NAME, modelId, SEARCH_PIPELINE1_NAME);
}
}
}

private void addDocuments(final String indexName, boolean isRunningAgainstOldCluster) throws IOException {
if (isRunningAgainstOldCluster) {
addDocument(indexName, "0", TEST_FIELD, TEXT_1, null, null);
addDocument(indexName, "1", TEST_FIELD, TEXT_2, null, null);
addDocument(indexName, "2", TEST_FIELD, TEXT_3, null, null);
addDocument(indexName, "3", TEST_FIELD, TEXT_4, null, null);
addDocument(indexName, "4", TEST_FIELD, TEXT_5, null, null);
} else {
addDocument(indexName, "5", TEST_FIELD, TEXT_6, null, null);
}
}

private void createSearchPipeline(final String pipelineName) {
createSearchPipeline(
pipelineName,
DEFAULT_NORMALIZATION_METHOD,
DEFAULT_COMBINATION_METHOD,
Map.of(PARAM_NAME_WEIGHTS, Arrays.toString(new float[] { 0.3f, 0.7f }))
);
}

private void validateTestIndex(final String modelId, final String index, final String searchPipeline) throws Exception {
int docCount = getDocCount(index);
assertEquals(6, docCount);
HybridQueryBuilder hybridQueryBuilder = getQueryBuilder(modelId);
Map<String, Object> searchResponseAsMap = search(index, hybridQueryBuilder, null, 1, Map.of("search_pipeline", searchPipeline));
assertNotNull(searchResponseAsMap);
int hits = getHitCount(searchResponseAsMap);
assertEquals(1, hits);
vibrantvarun marked this conversation as resolved.
Show resolved Hide resolved
List<Double> scoresList = getNormalizationScoreList(searchResponseAsMap);
for (Double score : scoresList) {
assertTrue(0 <= score && score <= 2);
}
}

public HybridQueryBuilder getQueryBuilder(final String modelId) {
NeuralQueryBuilder neuralQueryBuilder = new NeuralQueryBuilder();
neuralQueryBuilder.fieldName("passage_embedding");
neuralQueryBuilder.modelId(modelId);
neuralQueryBuilder.queryText(QUERY);
neuralQueryBuilder.k(5);

MatchQueryBuilder matchQueryBuilder = new MatchQueryBuilder("text", QUERY);

HybridQueryBuilder hybridQueryBuilder = new HybridQueryBuilder();
hybridQueryBuilder.add(matchQueryBuilder);
hybridQueryBuilder.add(neuralQueryBuilder);

return hybridQueryBuilder;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/
package org.opensearch.neuralsearch.bwc;

import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Map;
import static org.opensearch.neuralsearch.TestUtils.NODES_BWC_CLUSTER;
import static org.opensearch.neuralsearch.TestUtils.TEXT_IMAGE_EMBEDDING_PROCESSOR;
import static org.opensearch.neuralsearch.TestUtils.getModelId;
import org.opensearch.neuralsearch.query.NeuralQueryBuilder;

public class MultiModalSearchIT extends AbstractRestartUpgradeRestTestCase {
private static final String PIPELINE_NAME = "nlp-ingest-pipeline";
private static final String TEST_FIELD = "passage_text";
private static final String TEST_IMAGE_FIELD = "passage_image";
private static final String TEXT = "Hello world";
private static final String TEXT_1 = "Hello world a";
private static final String TEST_IMAGE_TEXT = "/9j/4AAQSkZJRgABAQAASABIAAD";
private static final String TEST_IMAGE_TEXT_1 = "/9j/4AAQSkZJRgbdwoeicfhoid";

// Test restart-upgrade test image embedding processor
// Create Text Image Embedding Processor, Ingestion Pipeline and add document
// Validate process , pipeline and document count in restart-upgrade scenario
public void testTextImageEmbeddingProcessor_E2EFlow() throws Exception {
vibrantvarun marked this conversation as resolved.
Show resolved Hide resolved
waitForClusterHealthGreen(NODES_BWC_CLUSTER);

if (isRunningAgainstOldCluster()) {
String modelId = uploadTextEmbeddingModel();
loadModel(modelId);
createPipelineForTextImageProcessor(modelId, PIPELINE_NAME);
createIndexWithConfiguration(
getIndexNameForTest(),
Files.readString(Path.of(classLoader.getResource("processor/IndexMappingMultipleShard.json").toURI())),
PIPELINE_NAME
);
addDocument(getIndexNameForTest(), "0", TEST_FIELD, TEXT, TEST_IMAGE_FIELD, TEST_IMAGE_TEXT);
} else {
String modelId = null;
try {
modelId = getModelId(getIngestionPipeline(PIPELINE_NAME), TEXT_IMAGE_EMBEDDING_PROCESSOR);
loadModel(modelId);
addDocument(getIndexNameForTest(), "1", TEST_FIELD, TEXT_1, TEST_IMAGE_FIELD, TEST_IMAGE_TEXT_1);
validateTestIndex(modelId);
} finally {
wipeOfTestResources(getIndexNameForTest(), PIPELINE_NAME, modelId, null);
}
}
}

private void validateTestIndex(final String modelId) throws Exception {
int docCount = getDocCount(getIndexNameForTest());
assertEquals(2, docCount);
NeuralQueryBuilder neuralQueryBuilder = new NeuralQueryBuilder("passage_embedding", TEXT, TEST_IMAGE_TEXT, modelId, 1, null, null);
Map<String, Object> response = search(getIndexNameForTest(), neuralQueryBuilder, 1);
assertNotNull(response);
}

}
Loading
Loading