From 609d0ab2acbd1535e8445bc34a61a78f58dec3c4 Mon Sep 17 00:00:00 2001 From: Naveen Tatikonda Date: Wed, 24 May 2023 15:51:40 -0500 Subject: [PATCH 1/8] Add Auto Release Workflow (#167) Signed-off-by: Naveen Tatikonda --- .github/workflows/auto-release.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/workflows/auto-release.yml diff --git a/.github/workflows/auto-release.yml b/.github/workflows/auto-release.yml new file mode 100644 index 000000000..10a9e1a45 --- /dev/null +++ b/.github/workflows/auto-release.yml @@ -0,0 +1,28 @@ +name: Releases + +on: + push: + tags: + - '*' + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: GitHub App token + id: github_app_token + uses: tibdex/github-app-token@v1.5.0 + with: + app_id: ${{ secrets.APP_ID }} + private_key: ${{ secrets.APP_PRIVATE_KEY }} + installation_id: 22958780 + - name: Get tag + id: tag + uses: dawidd6/action-get-tag@v1 + - uses: actions/checkout@v2 + - uses: ncipollo/release-action@v1 + with: + github_token: ${{ steps.github_app_token.outputs.token }} + bodyFile: release-notes/opensearch-neural-search.release-notes-${{steps.tag.outputs.tag}}.md From 637bbe1fea8befbfb33d2efa6b7de8d21c5c478a Mon Sep 17 00:00:00 2001 From: Martin Gaievski Date: Fri, 26 May 2023 08:36:14 -0700 Subject: [PATCH 2/8] Adding 2.8 release notes (#178) Signed-off-by: Martin Gaievski --- CHANGELOG.md | 1 - .../opensearch-neural-search.release-notes-2.8.0.0.md | 7 +++++++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 release-notes/opensearch-neural-search.release-notes-2.8.0.0.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 744ff88b7..f31d25198 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,7 +17,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Enhancements ### Bug Fixes ### Infrastructure -* Bump gradle version to 8.1.1 ([#169](https://github.com/opensearch-project/neural-search/pull/169)) ### Documentation ### Maintenance ### Refactoring \ No newline at end of file diff --git a/release-notes/opensearch-neural-search.release-notes-2.8.0.0.md b/release-notes/opensearch-neural-search.release-notes-2.8.0.0.md new file mode 100644 index 000000000..378ee856b --- /dev/null +++ b/release-notes/opensearch-neural-search.release-notes-2.8.0.0.md @@ -0,0 +1,7 @@ +## Version 2.8.0.0 Release Notes + +Compatible with OpenSearch 2.8.0 + +### Infrastructure + +* Bump gradle version to 8.1.1 ([#169](https://github.com/opensearch-project/neural-search/pull/169)) From 12116a4982d494e85d2ed9976c69dab4d32aa9ec Mon Sep 17 00:00:00 2001 From: Martin Gaievski Date: Wed, 7 Jun 2023 07:47:34 -0700 Subject: [PATCH 3/8] Delete model after each test in integ tests (#197) Signed-off-by: Martin Gaievski --- .../common/BaseNeuralSearchIT.java | 35 +++++++++++++++---- .../neuralsearch/query/NeuralQueryIT.java | 16 +++++++-- 2 files changed, 43 insertions(+), 8 deletions(-) diff --git a/src/test/java/org/opensearch/neuralsearch/common/BaseNeuralSearchIT.java b/src/test/java/org/opensearch/neuralsearch/common/BaseNeuralSearchIT.java index 7d83c5122..bbdfc27e4 100644 --- a/src/test/java/org/opensearch/neuralsearch/common/BaseNeuralSearchIT.java +++ b/src/test/java/org/opensearch/neuralsearch/common/BaseNeuralSearchIT.java @@ -56,6 +56,7 @@ public abstract class BaseNeuralSearchIT extends OpenSearchSecureRestTestCase { private static final int MAX_TASK_RESULT_QUERY_TIME_IN_SECOND = 60 * 5; private static final int DEFAULT_TASK_RESULT_QUERY_INTERVAL_IN_MILLISECOND = 1000; + private static final String DEFAULT_USER_AGENT = "Kibana"; protected final ClassLoader classLoader = this.getClass().getClassLoader(); @@ -93,7 +94,7 @@ protected String uploadModel(String requestBody) throws Exception { "/_plugins/_ml/models/_upload", null, toHttpEntity(requestBody), - ImmutableList.of(new BasicHeader(HttpHeaders.USER_AGENT, "Kibana")) + ImmutableList.of(new BasicHeader(HttpHeaders.USER_AGENT, DEFAULT_USER_AGENT)) ); Map uploadResJson = XContentHelper.convertToMap( XContentFactory.xContent(XContentType.JSON), @@ -122,7 +123,7 @@ protected void loadModel(String modelId) throws Exception { String.format(LOCALE, "/_plugins/_ml/models/%s/_load", modelId), null, toHttpEntity(""), - ImmutableList.of(new BasicHeader(HttpHeaders.USER_AGENT, "Kibana")) + ImmutableList.of(new BasicHeader(HttpHeaders.USER_AGENT, DEFAULT_USER_AGENT)) ); Map uploadResJson = XContentHelper.convertToMap( XContentFactory.xContent(XContentType.JSON), @@ -170,7 +171,7 @@ protected float[] runInference(String modelId, String queryText) { String.format(LOCALE, "/_plugins/_ml/_predict/text_embedding/%s", modelId), null, toHttpEntity(String.format(LOCALE, "{\"text_docs\": [\"%s\"],\"target_response\": [\"sentence_embedding\"]}", queryText)), - ImmutableList.of(new BasicHeader(HttpHeaders.USER_AGENT, "Kibana")) + ImmutableList.of(new BasicHeader(HttpHeaders.USER_AGENT, DEFAULT_USER_AGENT)) ); Map inferenceResJson = XContentHelper.convertToMap( @@ -201,7 +202,7 @@ protected void createIndexWithConfiguration(String indexName, String indexConfig indexName, null, toHttpEntity(indexConfiguration), - ImmutableList.of(new BasicHeader(HttpHeaders.USER_AGENT, "Kibana")) + ImmutableList.of(new BasicHeader(HttpHeaders.USER_AGENT, DEFAULT_USER_AGENT)) ); Map node = XContentHelper.convertToMap( XContentFactory.xContent(XContentType.JSON), @@ -225,7 +226,7 @@ protected void createPipelineProcessor(String modelId, String pipelineName) thro modelId ) ), - ImmutableList.of(new BasicHeader(HttpHeaders.USER_AGENT, "Kibana")) + ImmutableList.of(new BasicHeader(HttpHeaders.USER_AGENT, DEFAULT_USER_AGENT)) ); Map node = XContentHelper.convertToMap( XContentFactory.xContent(XContentType.JSON), @@ -403,7 +404,7 @@ protected Map getTaskQueryResponse(String taskId) throws Excepti String.format(LOCALE, "_plugins/_ml/tasks/%s", taskId), null, toHttpEntity(""), - ImmutableList.of(new BasicHeader(HttpHeaders.USER_AGENT, "Kibana")) + ImmutableList.of(new BasicHeader(HttpHeaders.USER_AGENT, DEFAULT_USER_AGENT)) ); return XContentHelper.convertToMap( XContentFactory.xContent(XContentType.JSON), @@ -491,4 +492,26 @@ protected static class KNNFieldConfig { private final Integer dimension; private final SpaceType spaceType; } + + @SneakyThrows + protected void deleteModel(String modelId) { + // need to undeploy first as model can be in use + makeRequest( + client(), + "POST", + String.format(LOCALE, "/_plugins/_ml/models/%s/_undeploy", modelId), + null, + toHttpEntity(""), + ImmutableList.of(new BasicHeader(HttpHeaders.USER_AGENT, DEFAULT_USER_AGENT)) + ); + + makeRequest( + client(), + "DELETE", + String.format(LOCALE, "/_plugins/_ml/models/%s", modelId), + null, + toHttpEntity(""), + ImmutableList.of(new BasicHeader(HttpHeaders.USER_AGENT, DEFAULT_USER_AGENT)) + ); + } } diff --git a/src/test/java/org/opensearch/neuralsearch/query/NeuralQueryIT.java b/src/test/java/org/opensearch/neuralsearch/query/NeuralQueryIT.java index 5c7ec335c..ab3ecb4dd 100644 --- a/src/test/java/org/opensearch/neuralsearch/query/NeuralQueryIT.java +++ b/src/test/java/org/opensearch/neuralsearch/query/NeuralQueryIT.java @@ -8,7 +8,6 @@ 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; @@ -16,6 +15,7 @@ import lombok.SneakyThrows; +import org.junit.After; import org.junit.Before; import org.opensearch.index.query.BoolQueryBuilder; import org.opensearch.index.query.MatchAllQueryBuilder; @@ -48,6 +48,17 @@ public void setUp() throws Exception { modelId.compareAndSet(modelId.get(), 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.get()); + } + /** * Tests basic query: * { @@ -344,7 +355,8 @@ public void testFilterQuery() { assertEquals(expectedScore, objectToFloat(firstInnerHit.get("_score")), 0.0); } - 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, From e77370ef53097dc8d4acb490c76b60531c8473da Mon Sep 17 00:00:00 2001 From: Junqiu Lei Date: Tue, 11 Jul 2023 12:07:05 -0500 Subject: [PATCH 4/8] Add 2.9.0 release note (#209) * Add 2.9.0 release note Signed-off-by: Junqiu Lei --- .../opensearch-neural-search.release-notes-2.9.0.0.md | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 release-notes/opensearch-neural-search.release-notes-2.9.0.0.md diff --git a/release-notes/opensearch-neural-search.release-notes-2.9.0.0.md b/release-notes/opensearch-neural-search.release-notes-2.9.0.0.md new file mode 100644 index 000000000..63f70dd75 --- /dev/null +++ b/release-notes/opensearch-neural-search.release-notes-2.9.0.0.md @@ -0,0 +1,9 @@ +## Version 2.9.0.0 Release Notes + +Compatible with OpenSearch 2.9.0 + +### Maintenance +Increment version to 2.9.0-SNAPSHOT ([#191](https://github.com/opensearch-project/neural-search/pull/191)) + +### Bug Fixes +Fix update document with knnn_vector size not matching issue ([#208](https://github.com/opensearch-project/neural-search/pull/208)) From ca29bcee02289135258a81f3cfabb09cb2cc2ff1 Mon Sep 17 00:00:00 2001 From: zane-neo Date: Wed, 12 Jul 2023 12:00:24 +0800 Subject: [PATCH 5/8] Fix update document with knnn_vector size not matching issue (#212) Signed-off-by: zane-neo --- .../processor/TextEmbeddingProcessor.java | 6 +++--- .../processor/TextEmbeddingProcessorTests.java | 16 +++++++++++++++- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/opensearch/neuralsearch/processor/TextEmbeddingProcessor.java b/src/main/java/org/opensearch/neuralsearch/processor/TextEmbeddingProcessor.java index 736fecafc..482a8730c 100644 --- a/src/main/java/org/opensearch/neuralsearch/processor/TextEmbeddingProcessor.java +++ b/src/main/java/org/opensearch/neuralsearch/processor/TextEmbeddingProcessor.java @@ -105,7 +105,7 @@ public void execute(IngestDocument ingestDocument, BiConsumer { - appendVectorFieldsToDocument(ingestDocument, knnMap, vectors); + setVectorFieldsToDocument(ingestDocument, knnMap, vectors); handler.accept(ingestDocument, null); }, e -> { handler.accept(null, e); })); } @@ -115,11 +115,11 @@ public void execute(IngestDocument ingestDocument, BiConsumer knnMap, List> vectors) { + void setVectorFieldsToDocument(IngestDocument ingestDocument, Map knnMap, List> vectors) { Objects.requireNonNull(vectors, "embedding failed, inference returns null result!"); log.debug("Text embedding result fetched, starting build vector output!"); Map textEmbeddingResult = buildTextEmbeddingResult(knnMap, vectors, ingestDocument.getSourceAndMetadata()); - textEmbeddingResult.forEach(ingestDocument::appendFieldValue); + textEmbeddingResult.forEach(ingestDocument::setFieldValue); } @SuppressWarnings({ "unchecked" }) diff --git a/src/test/java/org/opensearch/neuralsearch/processor/TextEmbeddingProcessorTests.java b/src/test/java/org/opensearch/neuralsearch/processor/TextEmbeddingProcessorTests.java index d4a92f103..b406030f0 100644 --- a/src/test/java/org/opensearch/neuralsearch/processor/TextEmbeddingProcessorTests.java +++ b/src/test/java/org/opensearch/neuralsearch/processor/TextEmbeddingProcessorTests.java @@ -350,7 +350,7 @@ public void testProcessResponse_successful() throws Exception { Map knnMap = processor.buildMapWithKnnKeyAndOriginalValue(ingestDocument); List> modelTensorList = createMockVectorResult(); - processor.appendVectorFieldsToDocument(ingestDocument, knnMap, modelTensorList); + processor.setVectorFieldsToDocument(ingestDocument, knnMap, modelTensorList); assertEquals(12, ingestDocument.getSourceAndMetadata().size()); } @@ -398,6 +398,20 @@ public void testBuildVectorOutput_withNestedMap_successful() { assertNotNull(actionGamesKnn); } + public void test_updateDocument_appendVectorFieldsToDocument_successful() { + Map config = createPlainStringConfiguration(); + IngestDocument ingestDocument = createPlainIngestDocument(); + TextEmbeddingProcessor processor = createInstanceWithNestedMapConfiguration(config); + Map knnMap = processor.buildMapWithKnnKeyAndOriginalValue(ingestDocument); + List> modelTensorList = createMockVectorResult(); + processor.setVectorFieldsToDocument(ingestDocument, knnMap, modelTensorList); + + List> modelTensorList1 = createMockVectorResult(); + processor.setVectorFieldsToDocument(ingestDocument, knnMap, modelTensorList1); + assertEquals(12, ingestDocument.getSourceAndMetadata().size()); + assertEquals(2, ((List) ingestDocument.getSourceAndMetadata().get("oriKey6_knn")).size()); + } + private List> createMockVectorResult() { List> modelTensorList = new ArrayList<>(); List number1 = ImmutableList.of(1.234f, 2.354f); From a9adfe04ddcd005f3e247376a3cb6bd3f69a6003 Mon Sep 17 00:00:00 2001 From: Martin Gaievski Date: Fri, 14 Jul 2023 00:46:51 +0200 Subject: [PATCH 6/8] Fix compilation errors, change core package name in import (#219) Signed-off-by: Martin Gaievski --- .../opensearch/neuralsearch/plugin/NeuralSearch.java | 2 +- .../neuralsearch/query/NeuralQueryBuilder.java | 6 +++--- .../java/org/opensearch/neuralsearch/TestUtils.java | 2 +- .../neuralsearch/common/BaseNeuralSearchIT.java | 2 +- .../neuralsearch/query/NeuralQueryBuilderTests.java | 10 +++++----- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/opensearch/neuralsearch/plugin/NeuralSearch.java b/src/main/java/org/opensearch/neuralsearch/plugin/NeuralSearch.java index 0f7b6f684..6bf85e3b8 100644 --- a/src/main/java/org/opensearch/neuralsearch/plugin/NeuralSearch.java +++ b/src/main/java/org/opensearch/neuralsearch/plugin/NeuralSearch.java @@ -14,7 +14,7 @@ import org.opensearch.client.Client; import org.opensearch.cluster.metadata.IndexNameExpressionResolver; import org.opensearch.cluster.service.ClusterService; -import org.opensearch.common.io.stream.NamedWriteableRegistry; +import org.opensearch.core.common.io.stream.NamedWriteableRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.env.Environment; import org.opensearch.env.NodeEnvironment; diff --git a/src/main/java/org/opensearch/neuralsearch/query/NeuralQueryBuilder.java b/src/main/java/org/opensearch/neuralsearch/query/NeuralQueryBuilder.java index 50a246348..a7548dbe5 100644 --- a/src/main/java/org/opensearch/neuralsearch/query/NeuralQueryBuilder.java +++ b/src/main/java/org/opensearch/neuralsearch/query/NeuralQueryBuilder.java @@ -23,11 +23,11 @@ import org.apache.commons.lang.builder.HashCodeBuilder; import org.apache.lucene.search.Query; import org.opensearch.action.ActionListener; -import org.opensearch.common.ParsingException; import org.opensearch.common.SetOnce; -import org.opensearch.common.io.stream.StreamInput; -import org.opensearch.common.io.stream.StreamOutput; import org.opensearch.core.ParseField; +import org.opensearch.core.common.ParsingException; +import org.opensearch.core.common.io.stream.StreamInput; +import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; import org.opensearch.index.mapper.NumberFieldMapper; diff --git a/src/test/java/org/opensearch/neuralsearch/TestUtils.java b/src/test/java/org/opensearch/neuralsearch/TestUtils.java index 4f0c5129d..257545132 100644 --- a/src/test/java/org/opensearch/neuralsearch/TestUtils.java +++ b/src/test/java/org/opensearch/neuralsearch/TestUtils.java @@ -9,8 +9,8 @@ import java.util.Map; -import org.opensearch.common.bytes.BytesReference; import org.opensearch.common.xcontent.XContentHelper; +import org.opensearch.core.common.bytes.BytesReference; import org.opensearch.core.xcontent.XContentBuilder; public class TestUtils { diff --git a/src/test/java/org/opensearch/neuralsearch/common/BaseNeuralSearchIT.java b/src/test/java/org/opensearch/neuralsearch/common/BaseNeuralSearchIT.java index bbdfc27e4..978951a76 100644 --- a/src/test/java/org/opensearch/neuralsearch/common/BaseNeuralSearchIT.java +++ b/src/test/java/org/opensearch/neuralsearch/common/BaseNeuralSearchIT.java @@ -40,12 +40,12 @@ import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.common.xcontent.XContentHelper; import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.rest.RestStatus; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.index.query.QueryBuilder; import org.opensearch.knn.index.SpaceType; import org.opensearch.neuralsearch.OpenSearchSecureRestTestCase; -import org.opensearch.rest.RestStatus; import com.google.common.collect.ImmutableList; diff --git a/src/test/java/org/opensearch/neuralsearch/query/NeuralQueryBuilderTests.java b/src/test/java/org/opensearch/neuralsearch/query/NeuralQueryBuilderTests.java index 7f48e61f9..dda4713b9 100644 --- a/src/test/java/org/opensearch/neuralsearch/query/NeuralQueryBuilderTests.java +++ b/src/test/java/org/opensearch/neuralsearch/query/NeuralQueryBuilderTests.java @@ -31,14 +31,14 @@ import org.opensearch.action.ActionListener; import org.opensearch.client.Client; -import org.opensearch.common.ParsingException; -import org.opensearch.common.bytes.BytesReference; import org.opensearch.common.io.stream.BytesStreamOutput; -import org.opensearch.common.io.stream.FilterStreamInput; -import org.opensearch.common.io.stream.NamedWriteableAwareStreamInput; -import org.opensearch.common.io.stream.NamedWriteableRegistry; import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.core.ParseField; +import org.opensearch.core.common.ParsingException; +import org.opensearch.core.common.bytes.BytesReference; +import org.opensearch.core.common.io.stream.FilterStreamInput; +import org.opensearch.core.common.io.stream.NamedWriteableAwareStreamInput; +import org.opensearch.core.common.io.stream.NamedWriteableRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; From bfbf1ef4ef565fbcc9fede77023fe16dff385fc5 Mon Sep 17 00:00:00 2001 From: Martin Gaievski Date: Tue, 25 Jul 2023 18:34:28 +0200 Subject: [PATCH 7/8] Switch from XContentType to MediaType to fix compilation errors (#232) Signed-off-by: Martin Gaievski --- .../opensearch/neuralsearch/OpenSearchSecureRestTestCase.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/opensearch/neuralsearch/OpenSearchSecureRestTestCase.java b/src/test/java/org/opensearch/neuralsearch/OpenSearchSecureRestTestCase.java index 5a4f6d381..07f9e53d7 100644 --- a/src/test/java/org/opensearch/neuralsearch/OpenSearchSecureRestTestCase.java +++ b/src/test/java/org/opensearch/neuralsearch/OpenSearchSecureRestTestCase.java @@ -36,8 +36,8 @@ import org.opensearch.common.settings.Settings; import org.opensearch.common.unit.TimeValue; import org.opensearch.common.util.concurrent.ThreadContext; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.xcontent.DeprecationHandler; +import org.opensearch.core.xcontent.MediaType; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.XContentParser; import org.opensearch.test.rest.OpenSearchRestTestCase; @@ -150,7 +150,7 @@ protected boolean preserveIndicesUponCompletion() { @After public void deleteExternalIndices() throws IOException { final Response response = client().performRequest(new Request("GET", "/_cat/indices?format=json" + "&expand_wildcards=all")); - final XContentType xContentType = XContentType.fromMediaType(response.getEntity().getContentType()); + final MediaType xContentType = MediaType.fromMediaType(response.getEntity().getContentType()); try ( final XContentParser parser = xContentType.xContent() .createParser( From 2ff58a92c5884f5bb1cb88ba6a2f4a03f4524ff7 Mon Sep 17 00:00:00 2001 From: Martin Gaievski Date: Fri, 28 Jul 2023 23:46:03 +0200 Subject: [PATCH 8/8] Fixing test classes after core refactoring (#237) Signed-off-by: Martin Gaievski --- .../common/BaseNeuralSearchIT.java | 18 +++++++----------- .../processor/TextEmbeddingProcessorIT.java | 3 +-- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/test/java/org/opensearch/neuralsearch/common/BaseNeuralSearchIT.java b/src/test/java/org/opensearch/neuralsearch/common/BaseNeuralSearchIT.java index 978951a76..d3636e660 100644 --- a/src/test/java/org/opensearch/neuralsearch/common/BaseNeuralSearchIT.java +++ b/src/test/java/org/opensearch/neuralsearch/common/BaseNeuralSearchIT.java @@ -97,7 +97,7 @@ protected String uploadModel(String requestBody) throws Exception { ImmutableList.of(new BasicHeader(HttpHeaders.USER_AGENT, DEFAULT_USER_AGENT)) ); Map uploadResJson = XContentHelper.convertToMap( - XContentFactory.xContent(XContentType.JSON), + XContentType.JSON.xContent(), EntityUtils.toString(uploadResponse.getEntity()), false ); @@ -126,7 +126,7 @@ protected void loadModel(String modelId) throws Exception { ImmutableList.of(new BasicHeader(HttpHeaders.USER_AGENT, DEFAULT_USER_AGENT)) ); Map uploadResJson = XContentHelper.convertToMap( - XContentFactory.xContent(XContentType.JSON), + XContentType.JSON.xContent(), EntityUtils.toString(uploadResponse.getEntity()), false ); @@ -175,7 +175,7 @@ protected float[] runInference(String modelId, String queryText) { ); Map inferenceResJson = XContentHelper.convertToMap( - XContentFactory.xContent(XContentType.JSON), + XContentType.JSON.xContent(), EntityUtils.toString(inferenceResponse.getEntity()), false ); @@ -205,7 +205,7 @@ protected void createIndexWithConfiguration(String indexName, String indexConfig ImmutableList.of(new BasicHeader(HttpHeaders.USER_AGENT, DEFAULT_USER_AGENT)) ); Map node = XContentHelper.convertToMap( - XContentFactory.xContent(XContentType.JSON), + XContentType.JSON.xContent(), EntityUtils.toString(response.getEntity()), false ); @@ -229,7 +229,7 @@ protected void createPipelineProcessor(String modelId, String pipelineName) thro ImmutableList.of(new BasicHeader(HttpHeaders.USER_AGENT, DEFAULT_USER_AGENT)) ); Map node = XContentHelper.convertToMap( - XContentFactory.xContent(XContentType.JSON), + XContentType.JSON.xContent(), EntityUtils.toString(pipelineCreateResponse.getEntity()), false ); @@ -295,7 +295,7 @@ protected Map search(String index, QueryBuilder queryBuilder, Qu String responseBody = EntityUtils.toString(response.getEntity()); - return XContentHelper.convertToMap(XContentFactory.xContent(XContentType.JSON), responseBody, false); + return XContentHelper.convertToMap(XContentType.JSON.xContent(), responseBody, false); } /** @@ -406,11 +406,7 @@ protected Map getTaskQueryResponse(String taskId) throws Excepti toHttpEntity(""), ImmutableList.of(new BasicHeader(HttpHeaders.USER_AGENT, DEFAULT_USER_AGENT)) ); - return XContentHelper.convertToMap( - XContentFactory.xContent(XContentType.JSON), - EntityUtils.toString(taskQueryResponse.getEntity()), - false - ); + return XContentHelper.convertToMap(XContentType.JSON.xContent(), EntityUtils.toString(taskQueryResponse.getEntity()), false); } protected boolean checkComplete(Map node) { diff --git a/src/test/java/org/opensearch/neuralsearch/processor/TextEmbeddingProcessorIT.java b/src/test/java/org/opensearch/neuralsearch/processor/TextEmbeddingProcessorIT.java index 226a3878d..7cea20a41 100644 --- a/src/test/java/org/opensearch/neuralsearch/processor/TextEmbeddingProcessorIT.java +++ b/src/test/java/org/opensearch/neuralsearch/processor/TextEmbeddingProcessorIT.java @@ -13,7 +13,6 @@ import org.apache.hc.core5.http.io.entity.EntityUtils; import org.apache.hc.core5.http.message.BasicHeader; import org.opensearch.client.Response; -import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.common.xcontent.XContentHelper; import org.opensearch.common.xcontent.XContentType; import org.opensearch.neuralsearch.common.BaseNeuralSearchIT; @@ -71,7 +70,7 @@ private void ingestDocument() throws Exception { ImmutableList.of(new BasicHeader(HttpHeaders.USER_AGENT, "Kibana")) ); Map map = XContentHelper.convertToMap( - XContentFactory.xContent(XContentType.JSON), + XContentType.JSON.xContent(), EntityUtils.toString(response.getEntity()), false );