[ML] Fix order that DBQ is constructed
Also use Job.ID constant instead of string literal.
Kudos to for this one :)
Original commit: elastic/x-pack-elasticsearch@906b080110f97845ba1b9e94d8df343f99be8d6f
@@ -21,6 +21,7 @@ import org.elasticsearch.action.bulk.byscroll.DeleteByQueryRequest;
import org.elasticsearch.action.bulk.byscroll.BulkByScrollResponse;
import org.elasticsearch.tasks.TaskId;
import org.elasticsearch.xpack.ml.action.MlDeleteByQueryAction;
+import org.elasticsearch.xpack.ml.job.config.Job;
import java.util.function.Consumer;
@@ -69,8 +70,8 @@ public class JobStorageDeletionTask extends Task {
// Step 1. DeleteByQuery on the index, matching all docs with the right job_id
// -------
SearchRequest searchRequest = new SearchRequest(indexPattern);
- searchRequest.source(new SearchSourceBuilder().query(new TermQueryBuilder("job_id", jobId)));
DeleteByQueryRequest request = new DeleteByQueryRequest(searchRequest);
+ searchRequest.source(new SearchSourceBuilder().query(new TermQueryBuilder(Job.ID.getPreferredName(), jobId)));
request.setSlices(5);
client.execute(MlDeleteByQueryAction.INSTANCE, request,
