Update data frame analytics jobs APIedit

This functionality is experimental and may be changed or removed completely in a future release. Elastic will take a best effort approach to fix any issues, but experimental features are not subject to the support SLA of official GA features.

Updates an existing data frame analytics job. The API accepts an UpdateDataFrameAnalyticsRequest object as a request and returns an UpdateDataFrameAnalyticsResponse.

Update data frame analytics jobs requestedit

An UpdateDataFrameAnalyticsRequest requires the following argument:

UpdateDataFrameAnalyticsRequest request = new UpdateDataFrameAnalyticsRequest(update); 

The configuration of the data frame analytics job update to perform

Data frame analytics configuration updateedit

The DataFrameAnalyticsConfigUpdate object contains all the details about the data frame analytics job configuration update and contains the following arguments:

DataFrameAnalyticsConfigUpdate update = DataFrameAnalyticsConfigUpdate.builder()
    .setId("my-analytics-config")  
    .setDescription("new description")  
    .setModelMemoryLimit(new ByteSizeValue(128, ByteSizeUnit.MB))  
    .setMaxNumThreads(4) 
    .build();

The data frame analytics job ID

The human-readable description

The memory limit for the model created as part of the analysis process

The maximum number of threads to be used by the analysis

Synchronous executionedit

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

PutDataFrameAnalyticsResponse response = client.machineLearning().updateDataFrameAnalytics(request, 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 UpdateDataFrameAnalyticsRequest 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-data-frame-analytics method:

client.machineLearning().updateDataFrameAnalyticsAsync(request, RequestOptions.DEFAULT, listener); 

The UpdateDataFrameAnalyticsRequest 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-data-frame-analytics looks like:

ActionListener<PutDataFrameAnalyticsResponse> listener = new ActionListener<PutDataFrameAnalyticsResponse>() {
    @Override
    public void onResponse(PutDataFrameAnalyticsResponse response) {
        
    }

    @Override
    public void onFailure(Exception e) {
        
    }
};

Called when the execution is successfully completed.

Called when the whole UpdateDataFrameAnalyticsRequest fails.

Responseedit

The returned UpdateDataFrameAnalyticsResponse contains the updated data frame analytics job.

DataFrameAnalyticsConfig updatedConfig = response.getConfig();