---
name: "Search::Elasticsearch::Client::7_0::Direct::ML"
section: "3pm"
platform: "linux"
package: "libsearch-elasticsearch-perl"
version: "7.30-1"
release: "Debian 11 (Bullseye)"
platforms: ["linux"]
url: "https://new.carta.tech/Search::Elasticsearch::Client::7_0::Direct::ML"
---

# Search::Elasticsearch::Client::7\_0::Direct::ML(3pm)

Plugin providing ML API for Search::Elasticsearch 7.x

## NAME

Search::Elasticsearch::Client::7\_0::Direct::ML - Plugin providing ML API for Search::Elasticsearch 7.x

## VERSION

version 7.30

## SYNOPSIS

```
    my $response = $es->ml->start_datafeed(...)
```

### DESCRIPTION

This class extends the Search::Elasticsearch client with an `"ml"` namespace, to support the Machine Learning APIs \<https://www.elastic.co/guide/en/x-pack/7.0/xpack-ml.html\>.

The full documentation for the ML feature is available here: \<https://www.elastic.co/guide/en/x-pack/7.0/xpack-ml.html\>

## DATAFEED METHODS

### "put\_datafeed()"

```
    $response = $es->ml->put_datafeed(
        datafeed_id => $id      # required
        body        => {...}    # required
    )
```

The `"put_datafeed()"` method enables you to instantiate a datafeed.

See the put\_datafeed docs \<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-put-datafeed.html\> for more information.

Query string parameters:\
     `"error_trace"`,\
     `"human"`

### "delete\_datafeed()"

```
    $response = $es->xpack->ml->delete_datafeed(
        datafeed_id => $id      # required
    )
```

The `"delete_datafeed()"` method enables you to delete a datafeed.

See the delete\_datafeed docs \<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-datafeed.html\> for more information.

Query string parameters:\
     `"error_trace"`,\
     `"force"`,\
     `"human"`

### "start\_datafeed()"

```
    $response = $es->ml->start_datafeed(
        datafeed_id => $id      # required
    )
```

The `"start_datafeed()"` method enables you to start a datafeed.

See the start\_datafeed docs \<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-start-datafeed.html\> for more information.

Query string parameters:\
     `"end"`,\
     `"error_trace"`,\
     `"human"`,\
     `"start"`,\
     `"timeout"`

### "stop\_datafeed()"

```
    $response = $es->ml->stop_datafeed(
        datafeed_id => $id      # required
    )
```

The `"stop_datafeed()"` method enables you to stop a datafeed.

See the stop\_datafeed docs \<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-stop-datafeed.html\> for more information.

Query string parameters:\
     `"allow_no_datafeeds"`,\
     `"error_trace"`,\
     `"force"`,\
     `"human"`,\
     `"timeout"`

### "get\_datafeeds()"

```
    $response = $es->ml->get_datafeeds(
        datafeed_id => $id      # optional
    )
```

The `"get_datafeeds()"` method enables you to retrieve configuration information for datafeeds.

See the get\_datafeeds docs \<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-datafeed.html\> for more information.

Query string parameters:\
     `"allow_no_datafeeds"`,\
     `"error_trace"`,\
     `"human"`

### "get\_datafeed\_stats()"

```
    $response = $es->ml->get_datafeed_stats(
        datafeed_id => $id      # optional
    )
```

The `"get_datafeed_stats()"` method enables you to retrieve configuration information for datafeeds.

See the get\_datafeed\_stats docs \<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-datafeed-stats.html\> for more information.

Query string parameters:\
     `"allow_no_datafeeds"`,\
     `"error_trace"`,\
     `"human"`

### "preview\_datafeed()"

```
    $response = $es->ml->preview_datafeed(
        datafeed_id => $id      # required
    )
```

The `"preview_datafeed()"` method enables you to preview a datafeed.

See the preview\_datafeed docs \<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-preview-datafeed.html\> for more information.

Query string parameters:\
     `"error_trace"`,\
     `"human"`

### "update\_datafeed()"

```
    $response = $es->ml->update_datafeed(
        datafeed_id => $id      # required
        body        => {...}    # required
    )
```

The `"update_datafeed()"` method enables you to update certain properties of a datafeed.

See the update\_datafeed docs \<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-update-datafeed.html\> for more information.

Query string parameters:\
     `"error_trace"`,\
     `"human"`

## JOB METHODS

### "put\_job()"

```
    $response = $es->ml->put_job(
        job_id => $id           # required
        body        => {...}    # required
    )
```

The `"put_job()"` method enables you to instantiate a job.

See the put\_job docs \<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-put-job.html\> for more information.

Query string parameters:\
     `"error_trace"`,\
     `"human"`

### "delete\_job()"

```
    $response = $es->ml->delete_job(
        job_id => $id           # required
    )
```

The `"delete_job()"` method enables you to delete a job.

See the delete\_job docs \<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-job.html\> for more information.

Query string parameters:\
     `"error_trace"`,\
     `"force"`,\
     `"human"`,\
     `"wait_for_completion"`

### "open\_job()"

```
    $response = $es->ml->open_job(
        job_id => $id           # required
    )
```

The `"open_job()"` method enables you to open a closed job.

See the open\_job docs \<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-open-job.html\> for more information.

Query string parameters:\
     `"error_trace"`,\
     `"human"`

### "close\_job()"

```
    $response = $es->ml->close_job(
        job_id => $id           # required
    )
```

The `"close_job()"` method enables you to close an open job.

See the close\_job docs \<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-close-job.html\> for more information.

Query string parameters:\
     `"allow_no_jobs"`,\
     `"error_trace"`,\
     `"force"`,\
     `"human"`,\
     `"timeout"`

### "get\_jobs()"

```
    $response = $es->ml->get_jobs(
        job_id => $id           # optional
    )
```

The `"get_jobs()"` method enables you to retrieve configuration information for jobs.

See the get\_jobs docs \<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-job.html\> for more information.

Query string parameters:\
     `"allow_no_jobs"`,\
     `"error_trace"`,\
     `"human"`

### "get\_job\_stats()"

```
    $response = $es->ml->get_jobs_stats(
        job_id => $id           # optional
    )
```

The `"get_jobs_stats()"` method enables you to retrieve usage information for jobs.

See the get\_job\_statss docs \<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-job-stats.html\> for more information.

Query string parameters:\
     `"allow_no_jobs"`,\
     `"error_trace"`,\
     `"human"`

### "flush\_job()"

```
    $response = $es->ml->flush_job(
        job_id => $id           # required
    )
```

The `"flush_job()"` method forces any buffered data to be processed by the job.

See the flush\_job docs \<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-flush-job.html\> for more information.

Query string parameters:\
     `"advance_time"`,\
     `"calc_interm"`,\
     `"end"`,\
     `"error_trace"`,\
     `"human"`,\
     `"skip_time"`,\
     `"start"`

### "post\_data()"

```
    $response = $es->ml->post_data(
        job_id => $id           # required
        body   => [data]        # required
    )
```

The `"post_data()"` method enables you to send data to an anomaly detection job for analysis.

See the post\_data docs \<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-post-data.html\> for more information.

Query string parameters:\
     `"error_trace"`,\
     `"human"`,\
     `"reset_end"`,\
     `"reset_start"`

### "update\_job()"

```
    $response = $es->ml->update_job(
        job_id => $id           # required
        body        => {...}    # required
    )
```

The `"update_job()"` method enables you to update certain properties of a job.

See the update\_job docs \<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-update-job.html\> for more information.

Query string parameters:\
     `"error_trace"`,\
     `"human"`

### "delete\_expired\_data"

```
    $response = $es->ml->delete_expired_data(
    )
```

The `"delete_expired_data()"` method deletes expired machine learning data.

See the delete\_expired\_data docs \<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-expired-data.html\> for more information.

Query string parameters:\
     `"error_trace"`,\
     `"human"`

## CALENDAR METHODS

### "put\_calendar()"

```
    $response = $es->ml->put_calendar(
        calendar_id => $id      # required
        body        => {...}    # optional
    )
```

The `"put_calendar()"` method creates a new calendar.

Query string parameters:\
     `"error_trace"`,\
     `"human"`

See the put calendar docs \<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-put-calendar.html\> for more information.

### "delete\_calendar()"

```
    $response = $es->ml->delete_calendar(
        calendar_id => $id      # required
    )
```

The `"delete_calendar()"` method deletes the specified calendar

Query string parameters:\
     `"error_trace"`,\
     `"human"`

See the delete\_calendar docs \<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-calendar.html\> for more information.

### "put\_calendar\_job()"

```
    $response = $es->ml->put_calendar_job(
        calendar_id => $id,     # required
        job_id      => $id      # required
    )
```

The `"put_calendar_job()"` method adds a job to a calendar.

Query string parameters:\
     `"error_trace"`,\
     `"human"`

See the put\_calendar\_job docs \<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-put-calendar-job.html\> for more information.

### "delete\_calendar\_job()"

```
    $response = $es->ml->delete_calendar_job(
        calendar_id => $id,     # required
        job_id      => $id      # required
    )
```

The `"delete_calendar_job()"` method deletes a job from a calendar.

Query string parameters:\
     `"error_trace"`,\
     `"human"`

See the delete\_calendar\_job docs \<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-calendar-job.html\> for more information.

### "put\_calendar\_event()"

```
    $response = $es->ml->post_calendar_events(
        calendar_id => $id,     # required
        body        => {...}    # required
    )
```

The `"post_calendar_events()"` method adds scheduled events to a calendar.

Query string parameters:\
     `"error_trace"`,\
     `"human"`

See the post\_calendar\_events docs \<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-post-calendar-events.html\> for more information.

### "delete\_calendar\_event()"

```
    $response = $es->ml->delete_calendar_event(
        calendar_id => $id,     # required
        event_id    => $id      # required
    )
```

The `"delete_calendar_event()"` method deletes an event from a calendar.

Query string parameters:\
     `"error_trace"`,\
     `"human"`

See the delete\_calendar\_event docs \<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-calendar-event.html\> for more information.

### "get\_calendars()"

```
    $response = $es->ml->get_calendars(
        calendar_id => $id,     # optional
    )
```

The `"get_calendars()"` method returns the specified calendar or all calendars.

Query string parameters:\
     `"error_trace"`,\
     `"from"`,\
     `"human"`,\
     `"size"`

See the get\_calendars docs \<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-calendar-event.html\> for more information.

### "get\_calendar\_events()"

```
    $response = $es->ml->get_calendar_events(
        calendar_id => $id,     # required
    )
```

The `"get_calendar_events()"` method retrieves events from a calendar.

Query string parameters:\
     `"end"`,\
     `"error_trace"`,\
     `"from"`,\
     `"human"`,\
     `"job_id"`,\
     `"size"`,\
     `"start"`

See the get\_calendar\_events docs \<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-calendar-event.html\> for more information.

## FILTER METHODS

### "put\_filter()"

```
    $response = $es->ml->put_filter(
        filter_id   => $id,     # required
        body        => {...}    # required
    )
```

The `"put_filter()"` method creates a named filter.

Query string parameters:\
     `"error_trace"`,\
     `"human"`

See the put\_filter docs \<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-put-filter.html\> for more information.

### "update\_filter()"

```
    $response = $es->ml->update_filter(
        filter_id   => $id,     # required
        body        => {...}    # required
    )
```

The `"update_filter()"` method updates the description of a filter, adds items, or removes items.

Query string parameters:\
     `"error_trace"`,\
     `"human"`

See the update\_filter docs \<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-update-filter.html\> for more information.

### "get\_filters()"

```
    $response = $es->ml->get_filters(
        filter_id   => $id,     # optional
    )
```

The `"get_filters()"` method retrieves a named filter or all filters.

Query string parameters:\
     `"error_trace"`,\
     `"from"`,\
     `"human"`,\
     `"size"`

See the get\_filters docs \<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-filters.html\> for more information.

### "delete\_filter()"

```
    $response = $es->ml->delete_filter(
        filter_id   => $id,     # required
    )
```

The `"delete_filter()"` method deletes a named filter.

Query string parameters:\
     `"error_trace"`,\
     `"human"`

See the delete\_filters docs \<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-filter.html\> for more information.

## FORECAST METHODS

### "forecast()"

```
    $response = $es->ml->forecast(
        job_id      => $id      # required
    )
```

The `"forecast()"` method enables you to create a new forecast

See the forecast docs \<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-forecast.html\> for more information.

Query string parameters:\
     `"duration"`,\
     `"error_trace"`,\
     `"expires_in"`,\
     `"human"`

### "delete\_forecast()"

```
    $response = $es->ml->delete_forecast(
        forecast_id => $id,     # required
        job_id      => $id      # required
    )
```

The `"delete_forecast()"` method enables you to delete an existing forecast.

See the delete\_forecast docs \<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-forecast.html\> for more information.

Query string parameters:\
     `"allow_no_forecasts"`,\
     `"error_trace"`,\
     `"human"`,\
     `"timeout"`

## MODEL SNAPSHOT METHODS

### "delete\_model\_snapshot()"

```
    $response = $es->ml->delete_model_snapshot(
        snapshot_id => $id      # required
    )
```

The `"delete_model_snapshot()"` method enables you to delete an existing model snapshot.

See the delete\_model\_snapshot docs \<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-snapshot.html\> for more information.

Query string parameters:\
     `"error_trace"`,\
     `"human"`

### "get\_model\_snapshots()"

```
    $response = $es->ml->get_model_snapshots(
        job_id      => $job_id,         # required
        snapshot_id => $snapshot_id     # optional
    )
```

The `"get_model_snapshots()"` method enables you to retrieve information about model snapshots.

See the get\_model\_snapshots docs \<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-snapshot.html\> for more information.

Query string parameters:\
     `"desc"`,\
     `"end"`,\
     `"error_trace"`,\
     `"from"`,\
     `"human"`,\
     `"size"`,\
     `"sort"`,\
     `"start"`

### "revert\_model\_snapshot()"

```
    $response = $es->ml->revert_model_snapshot(
        job_id      => $job_id,         # required
        snapshot_id => $snapshot_id     # required
    )
```

The `"revert_model_snapshots()"` method enables you to revert to a specific snapshot.

See the revert\_model\_snapshot docs \<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-revert-snapshot.html\> for more information.

Query string parameters:\
     `"delete_intervening_results"`,\
     `"error_trace"`,\
     `"human"`

### "update\_model\_snapshot()"

```
    $response = $es->ml->update_model_snapshot(
        job_id      => $job_id,         # required
        snapshot_id => $snapshot_id     # required
    )
```

The `"update_model_snapshots()"` method enables you to update certain properties of a snapshot.

See the update\_model\_snapshot docs \<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-update-snapshot.html\> for more information.

Query string parameters:\
     `"error_trace"`,\
     `"human"`

## RESULT METHODS

### "get\_buckets()"

```
    $response = $es->ml->get_buckets(
        job_id      => $job_id,         # required
        timestamp   => $timestamp       # optional
    )
```

The `"get_buckets()"` method enables you to retrieve job results for one or more buckets.

See the get\_buckets docs \<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-bucket.html\> for more information.

Query string parameters:\
     `"anomaly_score"`,\
     `"desc"`,\
     `"end"`,\
     `"error_trace"`,\
     `"exclude_interim"`,\
     `"expand"`,\
     `"from"`,\
     `"human"`,\
     `"size"`,\
     `"sort"`,\
     `"start"`

### "get\_overall\_buckets()"

```
    $response = $es->ml->get_overall_buckets(
        job_id      => $job_id,         # required
    )
```

The `"get_overall_buckets()"` method retrieves overall bucket results that summarize the bucket results of multiple jobs.

See the get\_overall\_buckets docs \<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-overall-buckets.html\> for more information.

Query string parameters:\
     `"allow_no_jobs"`,\
     `"bucket_span"`,\
     `"end"`,\
     `"error_trace"`,\
     `"exclude_interim"`,\
     `"human"`,\
     `"overall_score"`,\
     `"start"`,\
     `"top_n"`

### "get\_categories()"

```
    $response = $es->ml->get_categories(
        job_id      => $job_id,         # required
        category_id => $category_id     # optional
    )
```

The `"get_categories()"` method enables you to retrieve job results for one or more categories.

See the get\_categories docs \<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-category.html\> for more information.

Query string parameters:\
     `"error_trace"`,\
     `"from"`,\
     `"human"`,\
     `"size"`

### "get\_influencers()"

```
    $response = $es->ml->get_influencers(
        job_id      => $job_id,         # required
    )
```

The `"get_influencers()"` method enables you to retrieve job results for one or more influencers.

See the get\_influencers docs \<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-influencer.html\> for more information.

Query string parameters:\
     `"desc"`,\
     `"end"`,\
     `"error_trace"`,\
     `"exclude_interim"`,\
     `"expand"`,\
     `"from"`,\
     `"human"`,\
     `"influencer_score"`,\
     `"size"`,\
     `"sort"`,\
     `"start"`

### "get\_records()"

```
    $response = $es->ml->get_records(
        job_id      => $job_id,         # required
    )
```

The `"get_records()"` method enables you to retrieve anomaly records for a job.

See the get\_records docs \<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-record.html\> for more information.

Query string parameters:\
     `"desc"`,\
     `"end"`,\
     `"error_trace"`,\
     `"exclude_interim"`,\
     `"expand"`,\
     `"from"`,\
     `"human"`,\
     `"record_score"`,\
     `"size"`,\
     `"sort"`,\
     `"start"`

## FILE STRUCTURE METHODS

### "find\_file\_structure"

```
    $response = $es->ml->find_file_structure(
        body    => { ... },         # required
    )
```

The `"find_file_structure()"` method finds the structure of a text file which contains data that is suitable to be ingested into Elasticsearch.

See the find\_file\_structure docs \<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-find-file-structure.html\> for more information.

Query string parameters:\
     `"charset"`,\
     `"column_names"`,\
     `"delimiter"`,\
     `"error_trace"`,\
     `"explain"`,\
     `"format"`,\
     `"grok_pattern"`,\
     `"has_header_row"`,\
     `"human"`,\
     `"lines_to_sample"`,\
     `"quote"`,\
     `"should_trim_fields"`,\
     `"timeout"`,\
     `"timestamp_field"`,\
     `"timestamp_format"`

## INFO METHODS

### "info"

```
    $response = $es->ml->info();
```

The `"info()"` method returns defaults and limits used by machine learning.

See the find\_file\_structure docs \<https://www.elastic.co/guide/en/elasticsearch/reference/current/get-ml-info.html\> for more information.

Query string parameters:\
     `"error_trace"`,\
     `"human"`

## UPGRADE METHODS

### "set\_upgrade\_mode"

```
    $response = $es->ml->set_upgrade_mode();
```

The `"set_upgrade_mode()"` method sets a cluster wide `"upgrade_mode"` setting that prepares machine learning indices for an upgrade.

See the set\_upgrade\_mode docs \<https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-set-upgrade-mode.html\> for more information.

Query string parameters:\
     `"enabled"`,\
     `"error_trace"`,\
     `"human"`,\
     `"timeout"`

## AUTHOR

Enrico Zimuel \<enrico.zimuel@elastic.co\>

## COPYRIGHT AND LICENSE

This software is Copyright (c) 2020 by Elasticsearch BV.

This is free software, licensed under:

```
  The Apache License, Version 2.0, January 2004
```
