diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/job/persistence/JobStorageDeletionTask.java b/plugin/src/main/java/org/elasticsearch/xpack/ml/job/persistence/JobStorageDeletionTask.java index f7d84e8d2c6..2af33c9899a 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/ml/job/persistence/JobStorageDeletionTask.java +++ b/plugin/src/main/java/org/elasticsearch/xpack/ml/job/persistence/JobStorageDeletionTask.java @@ -114,6 +114,7 @@ public class JobStorageDeletionTask extends Task { searchRequest.source(new SearchSourceBuilder().query(query)); searchRequest.indicesOptions(JobProvider.addIgnoreUnavailable(IndicesOptions.lenientExpandOpen())); request.setAbortOnVersionConflict(false); + request.setRefresh(true); client.execute(DeleteByQueryAction.INSTANCE, request, ActionListener.wrap( response -> finishedHandler.onResponse(true), @@ -149,6 +150,7 @@ public class JobStorageDeletionTask extends Task { searchRequest.source(new SearchSourceBuilder().query(query)); searchRequest.indicesOptions(JobProvider.addIgnoreUnavailable(IndicesOptions.lenientExpandOpen())); request.setAbortOnVersionConflict(false); + request.setRefresh(true); client.execute(DeleteByQueryAction.INSTANCE, request, ActionListener.wrap( response -> { diff --git a/plugin/src/test/resources/rest-api-spec/test/ml/index_layout.yml b/plugin/src/test/resources/rest-api-spec/test/ml/index_layout.yml index 66cb59a755d..28d4ea804aa 100644 --- a/plugin/src/test/resources/rest-api-spec/test/ml/index_layout.yml +++ b/plugin/src/test/resources/rest-api-spec/test/ml/index_layout.yml @@ -180,9 +180,6 @@ index: ".ml-anomalies-shared" - is_true: '' - - do: - indices.refresh: {} - - do: count: index: .ml-state @@ -249,9 +246,6 @@ index: ".ml-anomalies-index-layout-job2" - is_false: '' - - do: - indices.refresh: {} - - do: count: type: doc @@ -379,9 +373,6 @@ index: "foo" - is_true: '' - - do: - indices.refresh: {} - - do: count: index: .ml-state @@ -392,6 +383,9 @@ index: .ml-anomalies-shared - match: {count: 0} + - do: + indices.refresh: {} + - do: count: index: foo @@ -436,9 +430,6 @@ job_id: "index-layout-quantiles-job" - match: { acknowledged: true } - - do: - indices.refresh: {} - - do: count: index: .ml-state @@ -509,17 +500,11 @@ body: state: more-new-categorizer-state - - do: - indices.refresh: {} - - do: xpack.ml.delete_job: job_id: "index-layout-state-job" - match: { acknowledged: true } - - do: - indices.refresh: {} - - do: count: index: .ml-anomalies-shared