Update anomaly detection jobs APIedit

Provides the ability to update an anomaly detection job. It accepts a UpdateJobRequest object and responds with a PutJobResponse object.

Update anomaly detection jobs requestedit

An UpdateJobRequest object gets created with a JobUpdate object.

UpdateJobRequest updateJobRequest = new UpdateJobRequest(update); 

Constructing a new request referencing a JobUpdate object.

Optional argumentsedit

The JobUpdate object has many optional arguments with which to update an existing anomaly detection job. An existing, non-null jobId must be referenced in its creation.

JobUpdate update = new JobUpdate.Builder(jobId) 
    .setDescription("My description") 
    .setAnalysisLimits(new AnalysisLimits(1000L, null)) 
    .setModelPlotConfig(new ModelPlotConfig(true, null, true)) 

Mandatory, non-null jobId referencing an existing anomaly detection job.

Updated description.

Updated analysis limits.

Updated background persistence interval.

Updated detectors through the JobUpdate.DetectorUpdate object.

Updated group membership.

Updated result retention.

Updated model plot configuration.

Updated model snapshot retention setting.

Updated custom settings.

Updated renormalization window.

Included with these options are specific optional JobUpdate.DetectorUpdate updates.

JobUpdate.DetectorUpdate detectorUpdate = new JobUpdate.DetectorUpdate(0, 
    "detector description", 

The index of the detector. O means unknown.

The optional description of the detector.

The DetectionRule rules that apply to this detector.

Synchronous executionedit

When executing a UpdateJobRequest in the following manner, the client waits for the PutJobResponse to be returned before continuing with code execution:

PutJobResponse updateJobResponse = client.machineLearning().updateJob(updateJobRequest, RequestOptions.DEFAULT);

Synchronous calls may throw an IOException in case of either failing to parse the REST response in the high-level REST client, the request times out or similar cases where there is no response coming back from the server.

In cases where the server returns a 4xx or 5xx error code, the high-level client tries to parse the response body error details instead and then throws a generic ElasticsearchException and adds the original ResponseException as a suppressed exception to it.

Asynchronous executionedit

Executing a UpdateJobRequest can also be done in an asynchronous fashion so that the client can return directly. Users need to specify how the response or potential failures will be handled by passing the request and a listener to the asynchronous update-job method:

client.machineLearning().updateJobAsync(updateJobRequest, RequestOptions.DEFAULT, listener); 

The UpdateJobRequest to execute and the ActionListener to use when the execution completes

The asynchronous method does not block and returns immediately. Once it is completed the ActionListener is called back using the onResponse method if the execution successfully completed or using the onFailure method if it failed. Failure scenarios and expected exceptions are the same as in the synchronous execution case.

A typical listener for update-job looks like:

ActionListener<PutJobResponse> listener = new ActionListener<PutJobResponse>() {
    public void onResponse(PutJobResponse updateJobResponse) {

    public void onFailure(Exception e) {

Called when the execution is successfully completed.

Called when the whole UpdateJobRequest fails.

Update anomaly detection jobs responseedit

A PutJobResponse contains the updated Job object

Job updatedJob = updateJobResponse.getResponse(); 

getResponse() returns the updated Job object.