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

[Backport feature/multi_tenancy] [Backport 2.15] Add XContentType to wrap the CreateIndexRequest mappings in _doc key to fix v1 templates issue #3049

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -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;
Expand Down Expand Up @@ -87,7 +88,7 @@ public void initConversationMetaIndexIfAbsent(ActionListener<Boolean> listener)
log.debug("No conversational meta index found. Adding it");
CreateIndexRequest request = Requests
.createIndexRequest(META_INDEX_NAME)
.mapping(ConversationalIndexConstants.META_MAPPING)
.mapping(ConversationalIndexConstants.META_MAPPING, XContentType.JSON)
.settings(INDEX_SETTINGS);
try (ThreadContext.StoredContext threadContext = client.threadPool().getThreadContext().stashContext()) {
ActionListener<Boolean> internalListener = ActionListener.runBefore(listener, () -> threadContext.restore());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -90,7 +91,7 @@ public void initInteractionsIndexIfAbsent(ActionListener<Boolean> listener) {
log.debug("No messages index found. Adding it");
CreateIndexRequest request = Requests
.createIndexRequest(INTERACTIONS_INDEX_NAME)
.mapping(ConversationalIndexConstants.INTERACTIONS_MAPPINGS)
.mapping(ConversationalIndexConstants.INTERACTIONS_MAPPINGS, XContentType.JSON)
.settings(INDEX_SETTINGS);
try (ThreadContext.StoredContext threadContext = client.threadPool().getThreadContext().stashContext()) {
ActionListener<Boolean> internalListener = ActionListener.runBefore(listener, () -> threadContext.restore());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ public void execute(Input input, ActionListener<org.opensearch.ml.common.output.
boolean hasModelGroupIndex = clusterService.state().getMetadata().hasIndex(ML_MODEL_GROUP_INDEX);
if (!hasModelGroupIndex) { // Create model group index if it doesn't exist
try (ThreadContext.StoredContext context = client.threadPool().getThreadContext().stashContext()) {
CreateIndexRequest request = new CreateIndexRequest(ML_MODEL_GROUP_INDEX).mapping(ML_MODEL_GROUP_INDEX_MAPPING);
CreateIndexRequest request = new CreateIndexRequest(ML_MODEL_GROUP_INDEX)
.mapping(ML_MODEL_GROUP_INDEX_MAPPING, XContentType.JSON);
CreateIndexResponse createIndexResponse = client.admin().indices().create(request).actionGet(1000);
if (!createIndexResponse.isAcknowledged()) {
throw new MLException("Failed to create model group index");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public void initMLIndexIfAbsent(MLIndex index, ActionListener<Boolean> listener)
internalListener.onFailure(e);
}
});
CreateIndexRequest request = new CreateIndexRequest(indexName).mapping(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);
Expand Down
Loading