diff --git a/spi/src/main/java/org/opensearch/jobscheduler/spi/utils/LockService.java b/spi/src/main/java/org/opensearch/jobscheduler/spi/utils/LockService.java index 4e75f525..19c5fb58 100644 --- a/spi/src/main/java/org/opensearch/jobscheduler/spi/utils/LockService.java +++ b/spi/src/main/java/org/opensearch/jobscheduler/spi/utils/LockService.java @@ -26,6 +26,7 @@ import org.opensearch.client.Client; import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.xcontent.LoggingDeprecationHandler; +import org.opensearch.core.xcontent.MediaType; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.common.xcontent.XContentFactory; @@ -82,7 +83,10 @@ void createLockIndex(ActionListener listener) { if (lockIndexExist()) { listener.onResponse(true); } else { - final CreateIndexRequest request = new CreateIndexRequest(LOCK_INDEX_NAME).mapping(lockMapping()); + final CreateIndexRequest request = new CreateIndexRequest(LOCK_INDEX_NAME).mapping( + lockMapping(), + (MediaType) XContentType.JSON + ); client.admin() .indices() .create(request, ActionListener.wrap(response -> listener.onResponse(response.isAcknowledged()), exception -> { diff --git a/src/main/java/org/opensearch/jobscheduler/utils/JobDetailsService.java b/src/main/java/org/opensearch/jobscheduler/utils/JobDetailsService.java index 3af7cb3d..4a112e1e 100644 --- a/src/main/java/org/opensearch/jobscheduler/utils/JobDetailsService.java +++ b/src/main/java/org/opensearch/jobscheduler/utils/JobDetailsService.java @@ -30,6 +30,7 @@ import org.opensearch.core.xcontent.XContentParser; import org.opensearch.common.xcontent.XContentType; import org.opensearch.extensions.action.ExtensionProxyAction; +import org.opensearch.core.xcontent.MediaType; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.common.xcontent.LoggingDeprecationHandler; import org.opensearch.index.IndexNotFoundException; @@ -293,7 +294,10 @@ void createJobDetailsIndex(ActionListener listener) { if (jobDetailsIndexExist()) { listener.onResponse(true); } else { - CreateIndexRequest request = new CreateIndexRequest(JOB_DETAILS_INDEX_NAME).mapping(jobDetailsMapping()); + CreateIndexRequest request = new CreateIndexRequest(JOB_DETAILS_INDEX_NAME).mapping( + jobDetailsMapping(), + (MediaType) XContentType.JSON + ); client.admin() .indices() .create(request, ActionListener.wrap(response -> listener.onResponse(response.isAcknowledged()), exception -> {