[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
This commit is contained in:
Benjamin Trent 2020-09-08 11:38:32 -04:00 committed by GitHub
parent f0e7d88699
commit 057bf3f7d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 0 deletions

View File

@ -227,6 +227,7 @@ public class MlConfigMigratorIT extends MlSingleNodeTestCase {
IndexRequest indexRequest = new IndexRequest(AnomalyDetectorsIndex.jobStateIndexWriteAlias()).id("ml-config") IndexRequest indexRequest = new IndexRequest(AnomalyDetectorsIndex.jobStateIndexWriteAlias()).id("ml-config")
.source(Collections.singletonMap("a_field", "a_value")) .source(Collections.singletonMap("a_field", "a_value"))
.opType(DocWriteRequest.OpType.CREATE) .opType(DocWriteRequest.OpType.CREATE)
.setRequireAlias(true)
.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); .setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE);
client().index(indexRequest).actionGet(); client().index(indexRequest).actionGet();

View File

@ -288,6 +288,7 @@ public class ResultsPersisterService {
private BulkRequest buildNewRequestFromFailures(BulkRequest bulkRequest, BulkResponse bulkResponse) { private BulkRequest buildNewRequestFromFailures(BulkRequest bulkRequest, BulkResponse bulkResponse) {
// If we failed, lets set the bulkRequest to be a collection of the failed requests // If we failed, lets set the bulkRequest to be a collection of the failed requests
BulkRequest bulkRequestOfFailures = new BulkRequest(); BulkRequest bulkRequestOfFailures = new BulkRequest();
bulkRequestOfFailures.requireAlias(bulkRequest.requireAlias());
Set<String> failedDocIds = Arrays.stream(bulkResponse.getItems()) Set<String> failedDocIds = Arrays.stream(bulkResponse.getItems())
.filter(BulkItemResponse::isFailed) .filter(BulkItemResponse::isFailed)
.map(BulkItemResponse::getId) .map(BulkItemResponse::getId)