[ML] Fix order that DBQ is constructed

Also use Job.ID constant instead of string literal.

Kudos to @dimitris-athanasiou for this one :)

Original commit: elastic/x-pack-elasticsearch@906b080110
This commit is contained in:
Zach 2017-02-15 15:52:00 -05:00
parent 6d79210f79
commit e441e0dc4e
1 changed files with 2 additions and 1 deletions

View File

@ -21,6 +21,7 @@ import org.elasticsearch.action.bulk.byscroll.DeleteByQueryRequest;
import org.elasticsearch.action.bulk.byscroll.BulkByScrollResponse; import org.elasticsearch.action.bulk.byscroll.BulkByScrollResponse;
import org.elasticsearch.tasks.TaskId; import org.elasticsearch.tasks.TaskId;
import org.elasticsearch.xpack.ml.action.MlDeleteByQueryAction; import org.elasticsearch.xpack.ml.action.MlDeleteByQueryAction;
import org.elasticsearch.xpack.ml.job.config.Job;
import java.util.function.Consumer; 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 // Step 1. DeleteByQuery on the index, matching all docs with the right job_id
// ------- // -------
SearchRequest searchRequest = new SearchRequest(indexPattern); SearchRequest searchRequest = new SearchRequest(indexPattern);
searchRequest.source(new SearchSourceBuilder().query(new TermQueryBuilder("job_id", jobId)));
DeleteByQueryRequest request = new DeleteByQueryRequest(searchRequest); DeleteByQueryRequest request = new DeleteByQueryRequest(searchRequest);
searchRequest.source(new SearchSourceBuilder().query(new TermQueryBuilder(Job.ID.getPreferredName(), jobId)));
request.setSlices(5); request.setSlices(5);
client.execute(MlDeleteByQueryAction.INSTANCE, request, client.execute(MlDeleteByQueryAction.INSTANCE, request,