---
type: api
title: Create a data frame analytics job
description: This API creates a data frame analytics job that performs an analysis on the
url: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/operation/operation-ml-put-data-frame-analytics
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/operation/operation-ml-put-data-frame-analytics
products:
  - Elasticsearch
---

# Create a data frame analytics job

Availability: 7.3+

## Paths

- `PUT` `/_ml/data_frame/analytics/{id}`

- [Api key auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/authentication#apikeyauth)
- [Basic auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/authentication#basicauth)
- [Bearer auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/authentication#bearerauth)

#### Path Parameters

- `id` (string Id)
  Identifier for the data frame analytics job. This identifier can contain
lowercase alphanumeric characters (a-z and 0-9), hyphens, and
underscores. It must start and end with alphanumeric characters.

## Description

This API creates a data frame analytics job that performs an analysis on the
source indices and stores the outcome in a destination index.
By default, the query used in the source configuration is `{"match_all": {}}`.

If the destination index does not exist, it is created automatically when you start the job.

If you supply only a subset of the regression or classification parameters, hyperparameter optimization occurs. It determines a value for each of the undefined parameters.

## Required authorization

* Index privileges: `create_index`,`index`,`manage`,`read`,`view_index_metadata`
* Cluster privileges: `manage_ml`

## Request Body

`application/json`

- `allow_lazy_start` (boolean · default: false) — optional
  Specifies whether this job can start when there is insufficient machine
learning node capacity for it to be immediately assigned to a node. If
set to `false` and a machine learning node with capacity to run the job
cannot be immediately found, the API returns an error. If set to `true`,
the API does not return an error; the job waits in the `starting` state
until sufficient machine learning node capacity is available. This
behavior is also affected by the cluster-wide
`xpack.ml.max_lazy_ml_nodes` setting.
- `analysis` ({} DataframeAnalysisContainer) — required
  The analysis configuration, which contains the information necessary to
perform one of the following types of analysis: classification, outlier
detection, or regression.
  - `classification` ({} DataframeAnalysisClassification) — optional
    The configuration information necessary to perform classification.
    - `alpha` (number) — optional
      Advanced configuration option. Machine learning uses loss guided tree growing, which means that the decision trees grow where the regularized loss decreases most quickly. This parameter affects loss calculations by acting as a multiplier of the tree depth. Higher alpha values result in shallower trees and faster training times. By default, this value is calculated during hyperparameter optimization. It must be greater than or equal to zero.
    - `dependent_variable` (string) — required
      Defines which field of the document is to be predicted. It must match one of the fields in the index being used to train. If this field is missing from a document, then that document will not be used for training, but a prediction with the trained model will be generated for it. It is also known as continuous target variable.
For classification analysis, the data type of the field must be numeric (`integer`, `short`, `long`, `byte`), categorical (`ip` or `keyword`), or `boolean`. There must be no more than 30 different values in this field.
For regression analysis, the data type of the field must be numeric.
    - `downsample_factor` (number) — optional
      Advanced configuration option. Controls the fraction of data that is used to compute the derivatives of the loss function for tree training. A small value results in the use of a small fraction of the data. If this value is set to be less than 1, accuracy typically improves. However, too small a value may result in poor convergence for the ensemble and so require more trees. By default, this value is calculated during hyperparameter optimization. It must be greater than zero and less than or equal to 1.
    - `early_stopping_enabled` (boolean · default: true) — optional
      Advanced configuration option. Specifies whether the training process should finish if it is not finding any better performing models. If disabled, the training process can take significantly longer and the chance of finding a better performing model is unremarkable.
    - `eta` (number) — optional
      Advanced configuration option. The shrinkage applied to the weights. Smaller values result in larger forests which have a better generalization error. However, larger forests cause slower training. By default, this value is calculated during hyperparameter optimization. It must be a value between 0.001 and 1.
    - `eta_growth_rate_per_tree` (number) — optional
      Advanced configuration option. Specifies the rate at which `eta` increases for each new tree that is added to the forest. For example, a rate of 1.05 increases `eta` by 5% for each extra tree. By default, this value is calculated during hyperparameter optimization. It must be between 0.5 and 2.
    - `feature_bag_fraction` (number) — optional
      Advanced configuration option. Defines the fraction of features that will be used when selecting a random bag for each candidate split. By default, this value is calculated during hyperparameter optimization.
    - `feature_processors` ([] DataframeAnalysisFeatureProcessor) — optional
      Advanced configuration option. A collection of feature preprocessors that modify one or more included fields. The analysis uses the resulting one or more features instead of the original document field. However, these features are ephemeral; they are not stored in the destination index. Multiple `feature_processors` entries can refer to the same document fields. Automatic categorical feature encoding still occurs for the fields that are unprocessed by a custom processor or that have categorical values. Use this property only if you want to override the automatic feature encoding of the specified fields.
      - `frequency_encoding` ({} DataframeAnalysisFeatureProcessorFrequencyEncoding) — optional
        The configuration information necessary to perform frequency encoding.
        - `feature_name` (string Name) — required
          The resulting feature name.
        - `field` (string Field) — required
        - `frequency_map` (map string to number) — required
          The resulting frequency map for the field value. If the field value is missing from the frequency_map, the resulting value is 0.
      - `multi_encoding` ({} DataframeAnalysisFeatureProcessorMultiEncoding) — optional
        The configuration information necessary to perform multi encoding. It allows multiple processors to be changed together. This way the output of a processor can then be passed to another as an input.
        - `processors` ([] number) — required
          The ordered array of custom processors to execute. Must be more than 1.
      - `n_gram_encoding` ({} DataframeAnalysisFeatureProcessorNGramEncoding) — optional
        The configuration information necessary to perform n-gram encoding. Features created by this encoder have the following name format: <feature_prefix>.<ngram><string position>. For example, if the feature_prefix is f, the feature name for the second unigram in a string is f.11.
        - `feature_prefix` (string) — optional
          The feature name prefix. Defaults to ngram_<start>_<length>.
        - `field` (string Field) — required
          The name of the text field to encode.
        - `length` (number) — optional
          Specifies the length of the n-gram substring. Defaults to 50. Must be greater than 0.
        - `n_grams` ([] number) — required
          Specifies which n-grams to gather. It’s an array of integer values where the minimum value is 1, and a maximum value is 5.
        - `start` (number) — optional
          Specifies the zero-indexed start of the n-gram substring. Negative values are allowed for encoding n-grams of string suffixes. Defaults to 0.
        - `custom` (boolean) — optional
      - `one_hot_encoding` ({} DataframeAnalysisFeatureProcessorOneHotEncoding) — optional
        The configuration information necessary to perform one hot encoding.
        - `field` (string Field) — required
          The name of the field to encode.
        - `hot_map` (string) — required
          The one hot map mapping the field value with the column name.
      - `target_mean_encoding` ({} DataframeAnalysisFeatureProcessorTargetMeanEncoding) — optional
        The configuration information necessary to perform target mean encoding.
        - `default_value` (number) — required
          The default value if field value is not found in the target_map.
        - `feature_name` (string Name) — required
          The resulting feature name.
        - `field` (string Field) — required
          The name of the field to encode.
        - `target_map` (map string to object) — required
          The field value to target mean transition map.
    - `gamma` (number) — optional
      Advanced configuration option. Regularization parameter to prevent overfitting on the training data set. Multiplies a linear penalty associated with the size of individual trees in the forest. A high gamma value causes training to prefer small trees. A small gamma value results in larger individual trees and slower training. By default, this value is calculated during hyperparameter optimization. It must be a nonnegative value.
    - `lambda` (number) — optional
      Advanced configuration option. Regularization parameter to prevent overfitting on the training data set. Multiplies an L2 regularization term which applies to leaf weights of the individual trees in the forest. A high lambda value causes training to favor small leaf weights. This behavior makes the prediction function smoother at the expense of potentially not being able to capture relevant relationships between the features and the dependent variable. A small lambda value results in large individual trees and slower training. By default, this value is calculated during hyperparameter optimization. It must be a nonnegative value.
    - `max_optimization_rounds_per_hyperparameter` (number) — optional
      Advanced configuration option. A multiplier responsible for determining the maximum number of hyperparameter optimization steps in the Bayesian optimization procedure. The maximum number of steps is determined based on the number of undefined hyperparameters times the maximum optimization rounds per hyperparameter. By default, this value is calculated during hyperparameter optimization.
    - `max_trees` (number) — optional
      Advanced configuration option. Defines the maximum number of decision trees in the forest. The maximum value is 2000. By default, this value is calculated during hyperparameter optimization.
    - `num_top_feature_importance_values` (number · default: 0) — optional
      Advanced configuration option. Specifies the maximum number of feature importance values per document to return. By default, no feature importance calculation occurs.
    - `prediction_field_name` (string Field) — optional
      Defines the name of the prediction field in the results. Defaults to `<dependent_variable>_prediction`.
    - `randomize_seed` (number) — optional
      Defines the seed for the random generator that is used to pick training data. By default, it is randomly generated. Set it to a specific value to use the same training data each time you start a job (assuming other related parameters such as `source` and `analyzed_fields` are the same).
    - `soft_tree_depth_limit` (number) — optional
      Advanced configuration option. Machine learning uses loss guided tree growing, which means that the decision trees grow where the regularized loss decreases most quickly. This soft limit combines with the `soft_tree_depth_tolerance` to penalize trees that exceed the specified depth; the regularized loss increases quickly beyond this depth. By default, this value is calculated during hyperparameter optimization. It must be greater than or equal to 0.
    - `soft_tree_depth_tolerance` (number) — optional
      Advanced configuration option. This option controls how quickly the regularized loss increases when the tree depth exceeds `soft_tree_depth_limit`. By default, this value is calculated during hyperparameter optimization. It must be greater than or equal to 0.01.
    - `training_percent` (number | string Percentage · default: 100) — optional
      Defines what percentage of the eligible documents that will be used for training. Documents that are ignored by the analysis (for example those that contain arrays with more than one value) won’t be included in the calculation for used percentage.
    - `class_assignment_objective` (string) — optional
    - `num_top_classes` (number · default: 2) — optional
      Defines the number of categories for which the predicted probabilities are reported. It must be non-negative or -1. If it is -1 or greater than the total number of categories, probabilities are reported for all categories; if you have a large number of categories, there could be a significant effect on the size of your destination index. NOTE: To use the AUC ROC evaluation method, `num_top_classes` must be set to -1 or a value greater than or equal to the total number of categories.
  - `outlier_detection` ({} DataframeAnalysisOutlierDetection) — optional
    The configuration information necessary to perform outlier detection. NOTE: Advanced parameters are for fine-tuning classification analysis. They are set automatically by hyperparameter optimization to give the minimum validation error. It is highly recommended to use the default values unless you fully understand the function of these parameters.
    - `compute_feature_influence` (boolean · default: true) — optional
      Specifies whether the feature influence calculation is enabled.
    - `feature_influence_threshold` (number · default: 0.1) — optional
      The minimum outlier score that a document needs to have in order to calculate its feature influence score. Value range: 0-1.
    - `method` (string · default: ensemble) — optional
      The method that outlier detection uses. Available methods are `lof`, `ldof`, `distance_kth_nn`, `distance_knn`, and `ensemble`. The default value is ensemble, which means that outlier detection uses an ensemble of different methods and normalises and combines their individual outlier scores to obtain the overall outlier score.
    - `n_neighbors` (number) — optional
      Defines the value for how many nearest neighbors each method of outlier detection uses to calculate its outlier score. When the value is not set, different values are used for different ensemble members. This default behavior helps improve the diversity in the ensemble; only override it if you are confident that the value you choose is appropriate for the data set.
    - `outlier_fraction` (number) — optional
      The proportion of the data set that is assumed to be outlying prior to outlier detection. For example, 0.05 means it is assumed that 5% of values are real outliers and 95% are inliers.
    - `standardization_enabled` (boolean · default: true) — optional
      If true, the following operation is performed on the columns before computing outlier scores: `(x_i - mean(x_i)) / sd(x_i)`.
  - `regression` ({} DataframeAnalysisRegression) — optional
    The configuration information necessary to perform regression. NOTE: Advanced parameters are for fine-tuning regression analysis. They are set automatically by hyperparameter optimization to give the minimum validation error. It is highly recommended to use the default values unless you fully understand the function of these parameters.
    - `alpha` (number) — optional
      Advanced configuration option. Machine learning uses loss guided tree growing, which means that the decision trees grow where the regularized loss decreases most quickly. This parameter affects loss calculations by acting as a multiplier of the tree depth. Higher alpha values result in shallower trees and faster training times. By default, this value is calculated during hyperparameter optimization. It must be greater than or equal to zero.
    - `dependent_variable` (string) — required
      Defines which field of the document is to be predicted. It must match one of the fields in the index being used to train. If this field is missing from a document, then that document will not be used for training, but a prediction with the trained model will be generated for it. It is also known as continuous target variable.
For classification analysis, the data type of the field must be numeric (`integer`, `short`, `long`, `byte`), categorical (`ip` or `keyword`), or `boolean`. There must be no more than 30 different values in this field.
For regression analysis, the data type of the field must be numeric.
    - `downsample_factor` (number) — optional
      Advanced configuration option. Controls the fraction of data that is used to compute the derivatives of the loss function for tree training. A small value results in the use of a small fraction of the data. If this value is set to be less than 1, accuracy typically improves. However, too small a value may result in poor convergence for the ensemble and so require more trees. By default, this value is calculated during hyperparameter optimization. It must be greater than zero and less than or equal to 1.
    - `early_stopping_enabled` (boolean · default: true) — optional
      Advanced configuration option. Specifies whether the training process should finish if it is not finding any better performing models. If disabled, the training process can take significantly longer and the chance of finding a better performing model is unremarkable.
    - `eta` (number) — optional
      Advanced configuration option. The shrinkage applied to the weights. Smaller values result in larger forests which have a better generalization error. However, larger forests cause slower training. By default, this value is calculated during hyperparameter optimization. It must be a value between 0.001 and 1.
    - `eta_growth_rate_per_tree` (number) — optional
      Advanced configuration option. Specifies the rate at which `eta` increases for each new tree that is added to the forest. For example, a rate of 1.05 increases `eta` by 5% for each extra tree. By default, this value is calculated during hyperparameter optimization. It must be between 0.5 and 2.
    - `feature_bag_fraction` (number) — optional
      Advanced configuration option. Defines the fraction of features that will be used when selecting a random bag for each candidate split. By default, this value is calculated during hyperparameter optimization.
    - `feature_processors` ([] DataframeAnalysisFeatureProcessor) — optional
      Advanced configuration option. A collection of feature preprocessors that modify one or more included fields. The analysis uses the resulting one or more features instead of the original document field. However, these features are ephemeral; they are not stored in the destination index. Multiple `feature_processors` entries can refer to the same document fields. Automatic categorical feature encoding still occurs for the fields that are unprocessed by a custom processor or that have categorical values. Use this property only if you want to override the automatic feature encoding of the specified fields.
      Same fields as `feature_processors` in `classification`
    - `gamma` (number) — optional
      Advanced configuration option. Regularization parameter to prevent overfitting on the training data set. Multiplies a linear penalty associated with the size of individual trees in the forest. A high gamma value causes training to prefer small trees. A small gamma value results in larger individual trees and slower training. By default, this value is calculated during hyperparameter optimization. It must be a nonnegative value.
    - `lambda` (number) — optional
      Advanced configuration option. Regularization parameter to prevent overfitting on the training data set. Multiplies an L2 regularization term which applies to leaf weights of the individual trees in the forest. A high lambda value causes training to favor small leaf weights. This behavior makes the prediction function smoother at the expense of potentially not being able to capture relevant relationships between the features and the dependent variable. A small lambda value results in large individual trees and slower training. By default, this value is calculated during hyperparameter optimization. It must be a nonnegative value.
    - `max_optimization_rounds_per_hyperparameter` (number) — optional
      Advanced configuration option. A multiplier responsible for determining the maximum number of hyperparameter optimization steps in the Bayesian optimization procedure. The maximum number of steps is determined based on the number of undefined hyperparameters times the maximum optimization rounds per hyperparameter. By default, this value is calculated during hyperparameter optimization.
    - `max_trees` (number) — optional
      Advanced configuration option. Defines the maximum number of decision trees in the forest. The maximum value is 2000. By default, this value is calculated during hyperparameter optimization.
    - `num_top_feature_importance_values` (number · default: 0) — optional
      Advanced configuration option. Specifies the maximum number of feature importance values per document to return. By default, no feature importance calculation occurs.
    - `prediction_field_name` (string Field) — optional
      Defines the name of the prediction field in the results. Defaults to `<dependent_variable>_prediction`.
    - `randomize_seed` (number) — optional
      Defines the seed for the random generator that is used to pick training data. By default, it is randomly generated. Set it to a specific value to use the same training data each time you start a job (assuming other related parameters such as `source` and `analyzed_fields` are the same).
    - `soft_tree_depth_limit` (number) — optional
      Advanced configuration option. Machine learning uses loss guided tree growing, which means that the decision trees grow where the regularized loss decreases most quickly. This soft limit combines with the `soft_tree_depth_tolerance` to penalize trees that exceed the specified depth; the regularized loss increases quickly beyond this depth. By default, this value is calculated during hyperparameter optimization. It must be greater than or equal to 0.
    - `soft_tree_depth_tolerance` (number) — optional
      Advanced configuration option. This option controls how quickly the regularized loss increases when the tree depth exceeds `soft_tree_depth_limit`. By default, this value is calculated during hyperparameter optimization. It must be greater than or equal to 0.01.
    - `training_percent` (number | string Percentage · default: 100) — optional
      Defines what percentage of the eligible documents that will be used for training. Documents that are ignored by the analysis (for example those that contain arrays with more than one value) won’t be included in the calculation for used percentage.
    - `loss_function` (string · default: mse) — optional
      The loss function used during regression. Available options are `mse` (mean squared error), `msle` (mean squared logarithmic error), `huber` (Pseudo-Huber loss).
    - `loss_function_parameter` (number) — optional
      A positive number that is used as a parameter to the `loss_function`.
- `analyzed_fields` ({} DataframeAnalysisAnalyzedFields) — optional
  Specifies `includes` and/or `excludes` patterns to select which fields
will be included in the analysis. The patterns specified in `excludes`
are applied last, therefore `excludes` takes precedence. In other words,
if the same field is specified in both `includes` and `excludes`, then
the field will not be included in the analysis. If `analyzed_fields` is
not set, only the relevant fields will be included. For example, all the
numeric fields for outlier detection.
The supported fields vary for each type of analysis. Outlier detection
requires numeric or `boolean` data to analyze. The algorithms don’t
support missing values therefore fields that have data types other than
numeric or boolean are ignored. Documents where included fields contain
missing values, null values, or an array are also ignored. Therefore the
`dest` index may contain documents that don’t have an outlier score.
Regression supports fields that are numeric, `boolean`, `text`,
`keyword`, and `ip` data types. It is also tolerant of missing values.
Fields that are supported are included in the analysis, other fields are
ignored. Documents where included fields contain an array with two or
more values are also ignored. Documents in the `dest` index that don’t
contain a results field are not included in the regression analysis.
Classification supports fields that are numeric, `boolean`, `text`,
`keyword`, and `ip` data types. It is also tolerant of missing values.
Fields that are supported are included in the analysis, other fields are
ignored. Documents where included fields contain an array with two or
more values are also ignored. Documents in the `dest` index that don’t
contain a results field are not included in the classification analysis.
Classification analysis can be improved by mapping ordinal variable
values to a single number. For example, in case of age ranges, you can
model the values as `0-14 = 0`, `15-24 = 1`, `25-34 = 2`, and so on.
  - `includes` ([] string) — required
    An array of strings that defines the fields that will be excluded from the analysis. You do not need to add fields with unsupported data types to excludes, these fields are excluded from the analysis automatically.
  - `excludes` ([] string) — required
    An array of strings that defines the fields that will be included in the analysis.
- `description` (string) — optional
  A description of the job.
- `dest` ({} DataframeAnalyticsDestination) — required
  The destination configuration.
  - `index` (string IndexName) — required
    Defines the destination index to store the results of the data frame analytics job.
  - `results_field` (string Field) — optional
    Defines the name of the field in which to store the results of the analysis. Defaults to `ml`.
- `max_num_threads` (number · default: 1) — optional
  The maximum number of threads to be used by the analysis. Using more
threads may decrease the time necessary to complete the analysis at the
cost of using more CPU. Note that the process may use additional threads
for operational functionality other than the analysis itself.
- `_meta` (Metadata) — optional
- `model_memory_limit` (string · default: 1gb) — optional
  The approximate maximum amount of memory resources that are permitted for
analytical processing. If your `elasticsearch.yml` file contains an
`xpack.ml.max_model_memory_limit` setting, an error occurs when you try
to create data frame analytics jobs that have `model_memory_limit` values
greater than that setting.
- `source` ({} DataframeAnalyticsSource) — required
  The configuration of how to source the analysis data.
  - `index` (string Indices) — required
    Index or indices on which to perform the analysis. It can be a single index or index pattern as well as an array of indices or patterns. NOTE: If your source indices contain documents with the same IDs, only the document that is indexed last appears in the destination index.
  - `runtime_mappings` (RuntimeFields) — optional
    Definitions of runtime fields that will become part of the mapping of the destination index.
  - `_source` ({} DataframeAnalysisAnalyzedFields) — optional
    Specify `includes` and/or `excludes patterns to select which fields will be present in the destination. Fields that are excluded cannot be included in the analysis.
    - `includes` ([] string) — required
      An array of strings that defines the fields that will be excluded from the analysis. You do not need to add fields with unsupported data types to excludes, these fields are excluded from the analysis automatically.
    - `excludes` ([] string) — required
      An array of strings that defines the fields that will be included in the analysis.
  - `query` (object) — optional
    The Elasticsearch query domain-specific language (DSL). This value corresponds to the query object in an Elasticsearch search POST body. All the options that are supported by Elasticsearch can be used, as this object is passed verbatim to Elasticsearch. By default, this property has the following value: `{"match_all": {}}`.
- `headers` (HttpHeaders) — optional
- `version` (string) — optional

## Response

`application/json`

- `authorization` ({} DataframeAnalyticsAuthorization)
  - `api_key` ({} ApiKeyAuthorization)
    If an API key was used for the most recent update to the job, its name and identifier are listed in the response.
    - `id` (string)
      The identifier for the API key.
    - `name` (string)
      The name of the API key.
  - `roles` ([] string)
    If a user ID was used for the most recent update to the job, its roles at the time of the update are listed in the response.
  - `service_account` (string)
    If a service account was used for the most recent update to the job, the account name is listed in the response.
- `allow_lazy_start` (boolean)
- `analysis` ({} DataframeAnalysisContainer)
  Same fields as `analysis`
- `analyzed_fields` ({} DataframeAnalysisAnalyzedFields)
  - `includes` ([] string)
    An array of strings that defines the fields that will be excluded from the analysis. You do not need to add fields with unsupported data types to excludes, these fields are excluded from the analysis automatically.
  - `excludes` ([] string)
    An array of strings that defines the fields that will be included in the analysis.
- `create_time` (EpochTimeUnitMillis)
- `description` (string)
- `dest` ({} DataframeAnalyticsDestination)
  - `index` (string IndexName)
    Defines the destination index to store the results of the data frame analytics job.
  - `results_field` (string Field)
    Defines the name of the field in which to store the results of the analysis. Defaults to `ml`.
- `id` (string Id)
- `max_num_threads` (number)
- `_meta` (Metadata)
- `model_memory_limit` (string)
- `source` ({} DataframeAnalyticsSource)
  - `index` (string Indices)
    Index or indices on which to perform the analysis. It can be a single index or index pattern as well as an array of indices or patterns. NOTE: If your source indices contain documents with the same IDs, only the document that is indexed last appears in the destination index.
  - `runtime_mappings` (RuntimeFields)
    Definitions of runtime fields that will become part of the mapping of the destination index.
  - `_source` ({} DataframeAnalysisAnalyzedFields)
    Specify `includes` and/or `excludes patterns to select which fields will be present in the destination. Fields that are excluded cannot be included in the analysis.
    - `includes` ([] string)
      An array of strings that defines the fields that will be excluded from the analysis. You do not need to add fields with unsupported data types to excludes, these fields are excluded from the analysis automatically.
    - `excludes` ([] string)
      An array of strings that defines the fields that will be included in the analysis.
  - `query` (object)
    The Elasticsearch query domain-specific language (DSL). This value corresponds to the query object in an Elasticsearch search POST body. All the options that are supported by Elasticsearch can be used, as this object is passed verbatim to Elasticsearch. By default, this property has the following value: `{"match_all": {}}`.
- `version` (string)
## Code Examples

#### Console

```console
PUT _ml/data_frame/analytics/model-flight-delays-pre
{
  "source": {
    "index": [
      "kibana_sample_data_flights"
    ],
    "query": {
      "range": {
        "DistanceKilometers": {
          "gt": 0
        }
      }
    },
    "_source": {
      "includes": [],
      "excludes": [
        "FlightDelay",
        "FlightDelayType"
      ]
    }
  },
  "dest": {
    "index": "df-flight-delays",
    "results_field": "ml-results"
  },
  "analysis": {
  "regression": {
    "dependent_variable": "FlightDelayMin",
    "training_percent": 90
    }
  },
  "analyzed_fields": {
    "includes": [],
    "excludes": [
      "FlightNum"
    ]
  },
  "model_memory_limit": "100mb"
}
```

#### JavaScript

```javascript
const response = await client.ml.putDataFrameAnalytics({
  id: "model-flight-delays-pre",
  source: {
    index: ["kibana_sample_data_flights"],
    query: {
      range: {
        DistanceKilometers: {
          gt: 0,
        },
      },
    },
    _source: {
      includes: [],
      excludes: ["FlightDelay", "FlightDelayType"],
    },
  },
  dest: {
    index: "df-flight-delays",
    results_field: "ml-results",
  },
  analysis: {
    regression: {
      dependent_variable: "FlightDelayMin",
      training_percent: 90,
    },
  },
  analyzed_fields: {
    includes: [],
    excludes: ["FlightNum"],
  },
  model_memory_limit: "100mb",
});
```

#### Python

```python
resp = client.ml.put_data_frame_analytics(
    id="model-flight-delays-pre",
    source={
        "index": [
            "kibana_sample_data_flights"
        ],
        "query": {
            "range": {
                "DistanceKilometers": {
                    "gt": 0
                }
            }
        },
        "_source": {
            "includes": [],
            "excludes": [
                "FlightDelay",
                "FlightDelayType"
            ]
        }
    },
    dest={
        "index": "df-flight-delays",
        "results_field": "ml-results"
    },
    analysis={
        "regression": {
            "dependent_variable": "FlightDelayMin",
            "training_percent": 90
        }
    },
    analyzed_fields={
        "includes": [],
        "excludes": [
            "FlightNum"
        ]
    },
    model_memory_limit="100mb",
)
```

#### curl

```curl
curl -X PUT "$ELASTICSEARCH_URL/_ml/data_frame/analytics/model-flight-delays-pre" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "source": {
      "index": [
        "kibana_sample_data_flights"
      ],
      "query": {
        "range": {
          "DistanceKilometers": {
            "gt": 0
          }
        }
      },
      "_source": {
        "includes": [],
        "excludes": [
          "FlightDelay",
          "FlightDelayType"
        ]
      }
    },
    "dest": {
      "index": "df-flight-delays",
      "results_field": "ml-results"
    },
    "analysis": {
      "regression": {
        "dependent_variable": "FlightDelayMin",
        "training_percent": 90
      }
    },
    "analyzed_fields": {
      "includes": [],
      "excludes": [
        "FlightNum"
      ]
    },
    "model_memory_limit": "100mb"
  }'
```

#### Java

```java
client.ml().putDataFrameAnalytics(p -> p
    .analysis(a -> a
        .regression(r -> r
            .dependentVariable("FlightDelayMin")
            .trainingPercent("90")
        )
    )
    .analyzedFields(an -> an
        .excludes("FlightNum")
    )
    .dest(d -> d
        .index("df-flight-delays")
        .resultsField("ml-results")
    )
    .id("model-flight-delays-pre")
    .modelMemoryLimit("100mb")
    .source(s -> s
        .index("kibana_sample_data_flights")
        .query(q -> q
            .range(r -> r
                .untyped(u -> u
                    .field("DistanceKilometers")
                    .gt(JsonData.fromJson("0"))
                )
            )
        )
        .source(so -> so
            .excludes(List.of("FlightDelay","FlightDelayType"))
        )
    )
);
```

#### C#

```c#
var response = await client.MachineLearning
    .PutDataFrameAnalyticsAsync(id: "model-flight-delays-pre", d1 => d1
        .Analysis(d2 => d2
            .Regression(d3 => d3
                .DependentVariable("FlightDelayMin")
                .TrainingPercent(new Percentage(90f))
            )
        )
        .AnalyzedFields(d2 => d2
            .Excludes("FlightNum")
            .Includes()
        )
        .Dest(d2 => d2
            .Index("df-flight-delays")
            .ResultsField(x => x.MlResults)
        )
        .ModelMemoryLimit("100mb")
        .Source(d2 => d2
            .Indices(new[] { "kibana_sample_data_flights" })
            .Query(d3 => d3
                .Range(new UntypedRangeQuery()
                {
                    Field = global::Elastic.Clients.Elasticsearch.Infer.Field<MyDocument>(x => x.DistanceKilometers),
                    Gt = 0
                })
            )
            .Source(d3 => d3
                .Excludes("FlightDelay", "FlightDelayType")
                .Includes()
            )
        )
    );
```

#### PHP

```php
$resp = $client->ml()->putDataFrameAnalytics([
    "id" => "model-flight-delays-pre",
    "body" => [
        "source" => [
            "index" => array(
                "kibana_sample_data_flights",
            ),
            "query" => [
                "range" => [
                    "DistanceKilometers" => [
                        "gt" => 0,
                    ],
                ],
            ],
            "_source" => [
                "includes" => array(
                ),
                "excludes" => array(
                    "FlightDelay",
                    "FlightDelayType",
                ),
            ],
        ],
        "dest" => [
            "index" => "df-flight-delays",
            "results_field" => "ml-results",
        ],
        "analysis" => [
            "regression" => [
                "dependent_variable" => "FlightDelayMin",
                "training_percent" => 90,
            ],
        ],
        "analyzed_fields" => [
            "includes" => array(
            ),
            "excludes" => array(
                "FlightNum",
            ),
        ],
        "model_memory_limit" => "100mb",
    ],
]);
```

#### Ruby

```ruby
response = client.ml.put_data_frame_analytics(
  id: "model-flight-delays-pre",
  body: {
    "source": {
      "index": [
        "kibana_sample_data_flights"
      ],
      "query": {
        "range": {
          "DistanceKilometers": {
            "gt": 0
          }
        }
      },
      "_source": {
        "includes": [],
        "excludes": [
          "FlightDelay",
          "FlightDelayType"
        ]
      }
    },
    "dest": {
      "index": "df-flight-delays",
      "results_field": "ml-results"
    },
    "analysis": {
      "regression": {
        "dependent_variable": "FlightDelayMin",
        "training_percent": 90
      }
    },
    "analyzed_fields": {
      "includes": [],
      "excludes": [
        "FlightNum"
      ]
    },
    "model_memory_limit": "100mb"
  }
)
```

