From a763379eda1053b66e71d557c3e6b82aa3501ae2 Mon Sep 17 00:00:00 2001 From: Bhavana Ramaram Date: Fri, 26 Jul 2024 12:33:06 -0500 Subject: [PATCH 1/4] Wrap CreateIndexRequest mappings in _doc key in ml-commons Signed-off-by: Bhavana Ramaram --- .../org/opensearch/ml/memory/index/ConversationMetaIndex.java | 2 +- .../org/opensearch/ml/memory/index/InteractionsIndex.java | 2 +- .../algorithms/metrics_correlation/MetricsCorrelation.java | 3 ++- .../org/opensearch/ml/engine/indices/MLIndicesHandler.java | 4 +++- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/memory/src/main/java/org/opensearch/ml/memory/index/ConversationMetaIndex.java b/memory/src/main/java/org/opensearch/ml/memory/index/ConversationMetaIndex.java index 21fba2bf9d..ed7669e244 100644 --- a/memory/src/main/java/org/opensearch/ml/memory/index/ConversationMetaIndex.java +++ b/memory/src/main/java/org/opensearch/ml/memory/index/ConversationMetaIndex.java @@ -87,7 +87,7 @@ public void initConversationMetaIndexIfAbsent(ActionListener listener) log.debug("No conversational meta index found. Adding it"); CreateIndexRequest request = Requests .createIndexRequest(META_INDEX_NAME) - .mapping(ConversationalIndexConstants.META_MAPPING) + .mapping("{\"_doc\":" + ConversationalIndexConstants.META_MAPPING + "}") .settings(INDEX_SETTINGS); try (ThreadContext.StoredContext threadContext = client.threadPool().getThreadContext().stashContext()) { ActionListener internalListener = ActionListener.runBefore(listener, () -> threadContext.restore()); diff --git a/memory/src/main/java/org/opensearch/ml/memory/index/InteractionsIndex.java b/memory/src/main/java/org/opensearch/ml/memory/index/InteractionsIndex.java index 0911a5785c..7c6332ce65 100644 --- a/memory/src/main/java/org/opensearch/ml/memory/index/InteractionsIndex.java +++ b/memory/src/main/java/org/opensearch/ml/memory/index/InteractionsIndex.java @@ -90,7 +90,7 @@ public void initInteractionsIndexIfAbsent(ActionListener listener) { log.debug("No messages index found. Adding it"); CreateIndexRequest request = Requests .createIndexRequest(INTERACTIONS_INDEX_NAME) - .mapping(ConversationalIndexConstants.INTERACTIONS_MAPPINGS) + .mapping("{\"_doc\":" + ConversationalIndexConstants.INTERACTIONS_MAPPINGS + "}") .settings(INDEX_SETTINGS); try (ThreadContext.StoredContext threadContext = client.threadPool().getThreadContext().stashContext()) { ActionListener internalListener = ActionListener.runBefore(listener, () -> threadContext.restore()); diff --git a/ml-algorithms/src/main/java/org/opensearch/ml/engine/algorithms/metrics_correlation/MetricsCorrelation.java b/ml-algorithms/src/main/java/org/opensearch/ml/engine/algorithms/metrics_correlation/MetricsCorrelation.java index eff2ec6fff..3b943665a9 100644 --- a/ml-algorithms/src/main/java/org/opensearch/ml/engine/algorithms/metrics_correlation/MetricsCorrelation.java +++ b/ml-algorithms/src/main/java/org/opensearch/ml/engine/algorithms/metrics_correlation/MetricsCorrelation.java @@ -130,7 +130,8 @@ public void execute(Input input, ActionListener listener) internalListener.onFailure(e); } }); - CreateIndexRequest request = new CreateIndexRequest(indexName).mapping(mapping).settings(INDEX_SETTINGS); + CreateIndexRequest request = new CreateIndexRequest(indexName) + .mapping("{\"_doc\":" + mapping + "}") + .settings(INDEX_SETTINGS); client.admin().indices().create(request, actionListener); } else { log.debug("index:{} is already created", indexName); From cea9faf17104c7467f972367f7a38f98a0a1189a Mon Sep 17 00:00:00 2001 From: Bhavana Ramaram Date: Fri, 26 Jul 2024 13:47:04 -0500 Subject: [PATCH 2/4] add commit to release notes Signed-off-by: Bhavana Ramaram --- release-notes/opensearch-ml-common.release-notes-2.16.0.0.md | 1 + 1 file changed, 1 insertion(+) diff --git a/release-notes/opensearch-ml-common.release-notes-2.16.0.0.md b/release-notes/opensearch-ml-common.release-notes-2.16.0.0.md index d110f5743e..8163291387 100644 --- a/release-notes/opensearch-ml-common.release-notes-2.16.0.0.md +++ b/release-notes/opensearch-ml-common.release-notes-2.16.0.0.md @@ -26,6 +26,7 @@ Compatible with OpenSearch 2.16.0 * Fix yaml test issue (#2700)[https://github.com/opensearch-project/ml-commons/pull/2700] * Fix MLModelTool returns null if the response of LLM is a pure json object (#2675)[https://github.com/opensearch-project/ml-commons/pull/2675] * Bump ml config index schema version (#2656)[https://github.com/opensearch-project/ml-commons/pull/2656] +* Wrap CreateIndexRequest mappings in _doc key in ml-commons (#2759)[https://github.com/opensearch-project/ml-commons/pull/2759] ### Maintenance * Upgrade djl version to 0.28.0 (#2578)[https://github.com/opensearch-project/ml-commons/pull/2578] From 25572e01b814964922a7110422aa06862ecab41c Mon Sep 17 00:00:00 2001 From: Bhavana Ramaram Date: Fri, 26 Jul 2024 16:44:22 -0500 Subject: [PATCH 3/4] use XContentType to add the _doc wrapper Signed-off-by: Bhavana Ramaram --- .../org/opensearch/ml/memory/index/ConversationMetaIndex.java | 3 ++- .../org/opensearch/ml/memory/index/InteractionsIndex.java | 3 ++- .../algorithms/metrics_correlation/MetricsCorrelation.java | 2 +- .../org/opensearch/ml/engine/indices/MLIndicesHandler.java | 4 +--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/memory/src/main/java/org/opensearch/ml/memory/index/ConversationMetaIndex.java b/memory/src/main/java/org/opensearch/ml/memory/index/ConversationMetaIndex.java index ed7669e244..d4dde66326 100644 --- a/memory/src/main/java/org/opensearch/ml/memory/index/ConversationMetaIndex.java +++ b/memory/src/main/java/org/opensearch/ml/memory/index/ConversationMetaIndex.java @@ -46,6 +46,7 @@ import org.opensearch.client.Requests; import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.util.concurrent.ThreadContext; +import org.opensearch.common.xcontent.XContentType; import org.opensearch.commons.ConfigConstants; import org.opensearch.commons.authuser.User; import org.opensearch.core.action.ActionListener; @@ -87,7 +88,7 @@ public void initConversationMetaIndexIfAbsent(ActionListener listener) log.debug("No conversational meta index found. Adding it"); CreateIndexRequest request = Requests .createIndexRequest(META_INDEX_NAME) - .mapping("{\"_doc\":" + ConversationalIndexConstants.META_MAPPING + "}") + .mapping(ConversationalIndexConstants.META_MAPPING, XContentType.JSON) .settings(INDEX_SETTINGS); try (ThreadContext.StoredContext threadContext = client.threadPool().getThreadContext().stashContext()) { ActionListener internalListener = ActionListener.runBefore(listener, () -> threadContext.restore()); diff --git a/memory/src/main/java/org/opensearch/ml/memory/index/InteractionsIndex.java b/memory/src/main/java/org/opensearch/ml/memory/index/InteractionsIndex.java index 7c6332ce65..ad31485e50 100644 --- a/memory/src/main/java/org/opensearch/ml/memory/index/InteractionsIndex.java +++ b/memory/src/main/java/org/opensearch/ml/memory/index/InteractionsIndex.java @@ -46,6 +46,7 @@ import org.opensearch.client.Requests; import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.util.concurrent.ThreadContext; +import org.opensearch.common.xcontent.XContentType; import org.opensearch.commons.ConfigConstants; import org.opensearch.commons.authuser.User; import org.opensearch.core.action.ActionListener; @@ -90,7 +91,7 @@ public void initInteractionsIndexIfAbsent(ActionListener listener) { log.debug("No messages index found. Adding it"); CreateIndexRequest request = Requests .createIndexRequest(INTERACTIONS_INDEX_NAME) - .mapping("{\"_doc\":" + ConversationalIndexConstants.INTERACTIONS_MAPPINGS + "}") + .mapping(ConversationalIndexConstants.INTERACTIONS_MAPPINGS, XContentType.JSON) .settings(INDEX_SETTINGS); try (ThreadContext.StoredContext threadContext = client.threadPool().getThreadContext().stashContext()) { ActionListener internalListener = ActionListener.runBefore(listener, () -> threadContext.restore()); diff --git a/ml-algorithms/src/main/java/org/opensearch/ml/engine/algorithms/metrics_correlation/MetricsCorrelation.java b/ml-algorithms/src/main/java/org/opensearch/ml/engine/algorithms/metrics_correlation/MetricsCorrelation.java index 3b943665a9..e6a15ecdae 100644 --- a/ml-algorithms/src/main/java/org/opensearch/ml/engine/algorithms/metrics_correlation/MetricsCorrelation.java +++ b/ml-algorithms/src/main/java/org/opensearch/ml/engine/algorithms/metrics_correlation/MetricsCorrelation.java @@ -131,7 +131,7 @@ public void execute(Input input, ActionListener listener) internalListener.onFailure(e); } }); - CreateIndexRequest request = new CreateIndexRequest(indexName) - .mapping("{\"_doc\":" + mapping + "}") - .settings(INDEX_SETTINGS); + CreateIndexRequest request = new CreateIndexRequest(indexName).mapping(mapping, XContentType.JSON).settings(INDEX_SETTINGS); client.admin().indices().create(request, actionListener); } else { log.debug("index:{} is already created", indexName); From d82318feb0dd8eb5870f494d377967a2a34f7be1 Mon Sep 17 00:00:00 2001 From: Bhavana Ramaram Date: Fri, 26 Jul 2024 17:09:18 -0500 Subject: [PATCH 4/4] remove release notes Signed-off-by: Bhavana Ramaram --- release-notes/opensearch-ml-common.release-notes-2.16.0.0.md | 1 - 1 file changed, 1 deletion(-) diff --git a/release-notes/opensearch-ml-common.release-notes-2.16.0.0.md b/release-notes/opensearch-ml-common.release-notes-2.16.0.0.md index 8163291387..d110f5743e 100644 --- a/release-notes/opensearch-ml-common.release-notes-2.16.0.0.md +++ b/release-notes/opensearch-ml-common.release-notes-2.16.0.0.md @@ -26,7 +26,6 @@ Compatible with OpenSearch 2.16.0 * Fix yaml test issue (#2700)[https://github.com/opensearch-project/ml-commons/pull/2700] * Fix MLModelTool returns null if the response of LLM is a pure json object (#2675)[https://github.com/opensearch-project/ml-commons/pull/2675] * Bump ml config index schema version (#2656)[https://github.com/opensearch-project/ml-commons/pull/2656] -* Wrap CreateIndexRequest mappings in _doc key in ml-commons (#2759)[https://github.com/opensearch-project/ml-commons/pull/2759] ### Maintenance * Upgrade djl version to 0.28.0 (#2578)[https://github.com/opensearch-project/ml-commons/pull/2578]