From 057bf3f7d53fe29636cc3cb5a66ddc5b2d459784 Mon Sep 17 00:00:00 2001 From: Benjamin Trent Date: Tue, 8 Sep 2020 11:38:32 -0400 Subject: [PATCH] [ML] setting require_alias to previous value on bulk index retry (#62103) (#62108) Previous work has been done to prevent automatically creating a concrete index when an alias is desired. This commit addresses a path where this check was not being done. relates: #62064 --- .../elasticsearch/xpack/ml/integration/MlConfigMigratorIT.java | 1 + .../xpack/ml/utils/persistence/ResultsPersisterService.java | 1 + 2 files changed, 2 insertions(+) diff --git a/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/MlConfigMigratorIT.java b/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/MlConfigMigratorIT.java index 0b172e56480..3bb36ea168a 100644 --- a/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/MlConfigMigratorIT.java +++ b/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/MlConfigMigratorIT.java @@ -227,6 +227,7 @@ public class MlConfigMigratorIT extends MlSingleNodeTestCase { IndexRequest indexRequest = new IndexRequest(AnomalyDetectorsIndex.jobStateIndexWriteAlias()).id("ml-config") .source(Collections.singletonMap("a_field", "a_value")) .opType(DocWriteRequest.OpType.CREATE) + .setRequireAlias(true) .setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); client().index(indexRequest).actionGet(); diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/utils/persistence/ResultsPersisterService.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/utils/persistence/ResultsPersisterService.java index 3c749acb793..98c9bc243f0 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/utils/persistence/ResultsPersisterService.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/utils/persistence/ResultsPersisterService.java @@ -288,6 +288,7 @@ public class ResultsPersisterService { private BulkRequest buildNewRequestFromFailures(BulkRequest bulkRequest, BulkResponse bulkResponse) { // If we failed, lets set the bulkRequest to be a collection of the failed requests BulkRequest bulkRequestOfFailures = new BulkRequest(); + bulkRequestOfFailures.requireAlias(bulkRequest.requireAlias()); Set failedDocIds = Arrays.stream(bulkResponse.getItems()) .filter(BulkItemResponse::isFailed) .map(BulkItemResponse::getId)