From d140b3028d0ab4dcf6c2091d7113d6af2177fbff Mon Sep 17 00:00:00 2001 From: Dimitrios Athanasiou Date: Wed, 3 May 2017 14:58:22 +0100 Subject: [PATCH] [ML] Reuse encapsulated delete-by-query request Original commit: elastic/x-pack-elasticsearch@cc0f2ce815d88f4060b41fc45b5b5b7d68d71df3 --- .../xpack/ml/job/persistence/JobDataDeleter.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/job/persistence/JobDataDeleter.java b/plugin/src/main/java/org/elasticsearch/xpack/ml/job/persistence/JobDataDeleter.java index 2860cb593cb..abeb8cc3893 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/ml/job/persistence/JobDataDeleter.java +++ b/plugin/src/main/java/org/elasticsearch/xpack/ml/job/persistence/JobDataDeleter.java @@ -105,18 +105,16 @@ public class JobDataDeleter { * Delete all results marked as interim */ public void deleteInterimResults() { - SearchRequest searchRequest = new SearchRequest(AnomalyDetectorsIndex.jobResultsAliasedName(jobId)); - DeleteByQueryRequest request = new DeleteByQueryRequest(searchRequest); - request.setRefresh(false); - request.setSlices(5); + DeleteByQueryHolder deleteByQueryHolder = new DeleteByQueryHolder(AnomalyDetectorsIndex.jobResultsAliasedName(jobId)); + deleteByQueryHolder.dbqRequest.setRefresh(false); - searchRequest.indicesOptions(IndicesOptions.lenientExpandOpen()); - searchRequest.types(Result.TYPE.getPreferredName()); + deleteByQueryHolder.searchRequest.indicesOptions(IndicesOptions.lenientExpandOpen()); + deleteByQueryHolder.searchRequest.types(Result.TYPE.getPreferredName()); QueryBuilder qb = QueryBuilders.termQuery(Bucket.IS_INTERIM.getPreferredName(), true); - searchRequest.source(new SearchSourceBuilder().query(new ConstantScoreQueryBuilder(qb))); + deleteByQueryHolder.searchRequest.source(new SearchSourceBuilder().query(new ConstantScoreQueryBuilder(qb))); try { - client.execute(XPackDeleteByQueryAction.INSTANCE, request).get(); + client.execute(XPackDeleteByQueryAction.INSTANCE, deleteByQueryHolder.dbqRequest).get(); } catch (Exception e) { LOGGER.error("[" + jobId + "] An error occurred while deleting interim results", e); }