# Transforms

class elasticsearch.client.TransformClient

  To use this client, access `client.transform` from an `Elasticsearch` client. For example:

      from elasticsearch import Elasticsearch

      # Create the client instance
      client = Elasticsearch(...)
      # Use the transform client
      client.transform.<method>(...)

  delete_transform(*, transform_id, delete_dest_index=None, error_trace=None, filter_path=None, force=None, human=None, pretty=None, timeout=None)

    Delete a transform. Deletes a transform.

    https://www.elastic.co/guide/en/elasticsearch/reference/8.17/delete-transform.html

    Parameters:

      - transform_id (str) – Identifier for the transform.

      - delete_dest_index (bool | None) – If this value is true, the destination index is deleted together with the transform. If false, the destination index will not be deleted

      - force (bool | None) – If this value is false, the transform must be stopped before it can be deleted. If true, the transform is deleted regardless of its current state.

      - timeout (str | Literal[-1] | ~typing.Literal[0] | None) – Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error.

      - error_trace (bool | None)

      - filter_path (str | Sequence[str] | None)

      - human (bool | None)

      - pretty (bool | None)

    Return type:

      ObjectApiResponse[Any]

  get_transform(*, transform_id=None, allow_no_match=None, error_trace=None, exclude_generated=None, filter_path=None, from_=None, human=None, pretty=None, size=None)

    Get transforms. Retrieves configuration information for transforms.

    https://www.elastic.co/guide/en/elasticsearch/reference/8.17/get-transform.html

    Parameters:

      - transform_id (str | Sequence[str] | None) – Identifier for the transform. It can be a transform identifier or a wildcard expression. You can get information for all transforms by using _all, by specifying * as the <transform_id>, or by omitting the <transform_id>.

      - allow_no_match (bool | None) – Specifies what to do when the request: 1. Contains wildcard expressions and there are no transforms that match. 2. Contains the _all string or no identifiers and there are no matches. 3. Contains wildcard expressions and there are only partial matches. If this parameter is false, the request returns a 404 status code when there are no matches or only partial matches.

      - exclude_generated (bool | None) – Excludes fields that were automatically added when creating the transform. This allows the configuration to be in an acceptable format to be retrieved and then added to another cluster.

      - from – Skips the specified number of transforms.

      - size (int | None) – Specifies the maximum number of transforms to obtain.

      - error_trace (bool | None)

      - filter_path (str | Sequence[str] | None)

      - from_ (int | None)

      - human (bool | None)

      - pretty (bool | None)

    Return type:

      ObjectApiResponse[Any]

  get_transform_stats(*, transform_id, allow_no_match=None, error_trace=None, filter_path=None, from_=None, human=None, pretty=None, size=None, timeout=None)

    Get transform stats. Retrieves usage information for transforms.

    https://www.elastic.co/guide/en/elasticsearch/reference/8.17/get-transform-stats.html

    Parameters:

      - transform_id (str | Sequence[str]) – Identifier for the transform. It can be a transform identifier or a wildcard expression. You can get information for all transforms by using _all, by specifying * as the <transform_id>, or by omitting the <transform_id>.

      - allow_no_match (bool | None) – Specifies what to do when the request: 1. Contains wildcard expressions and there are no transforms that match. 2. Contains the _all string or no identifiers and there are no matches. 3. Contains wildcard expressions and there are only partial matches. If this parameter is false, the request returns a 404 status code when there are no matches or only partial matches.

      - from – Skips the specified number of transforms.

      - size (int | None) – Specifies the maximum number of transforms to obtain.

      - timeout (str | Literal[-1] | ~typing.Literal[0] | None) – Controls the time to wait for the stats

      - error_trace (bool | None)

      - filter_path (str | Sequence[str] | None)

      - from_ (int | None)

      - human (bool | None)

      - pretty (bool | None)

    Return type:

      ObjectApiResponse[Any]

  preview_transform(*, transform_id=None, description=None, dest=None, error_trace=None, filter_path=None, frequency=None, human=None, latest=None, pivot=None, pretty=None, retention_policy=None, settings=None, source=None, sync=None, timeout=None, body=None)

    Preview a transform. Generates a preview of the results that you will get when you create a transform with the same configuration.

    It returns a maximum of 100 results. The calculations are based on all the current data in the source index. It also generates a list of mappings and settings for the destination index. These values are determined based on the field types of the source index and the transform aggregations.

    https://www.elastic.co/guide/en/elasticsearch/reference/8.17/preview-transform.html

    Parameters:

      - transform_id (str | None) – Identifier for the transform to preview. If you specify this path parameter, you cannot provide transform configuration details in the request body.

      - description (str | None) – Free text description of the transform.

      - dest (Mapping[str, Any] | None) – The destination for the transform.

      - frequency (str | Literal[-1] | ~typing.Literal[0] | None) – The interval between checks for changes in the source indices when the transform is running continuously. Also determines the retry interval in the event of transient failures while the transform is searching or indexing. The minimum value is 1s and the maximum is 1h.

      - latest (Mapping[str, Any] | None) – The latest method transforms the data by finding the latest document for each unique key.

      - pivot (Mapping[str, Any] | None) – The pivot method transforms the data by aggregating and grouping it. These objects define the group by fields and the aggregation to reduce the data.

      - retention_policy (Mapping[str, Any] | None) – Defines a retention policy for the transform. Data that meets the defined criteria is deleted from the destination index.

      - settings (Mapping[str, Any] | None) – Defines optional transform settings.

      - source (Mapping[str, Any] | None) – The source of the data for the transform.

      - sync (Mapping[str, Any] | None) – Defines the properties transforms require to run continuously.

      - timeout (str | Literal[-1] | ~typing.Literal[0] | None) – Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error.

      - error_trace (bool | None)

      - filter_path (str | Sequence[str] | None)

      - human (bool | None)

      - pretty (bool | None)

      - body (Dict[str, Any] | None)

    Return type:

      ObjectApiResponse[Any]

  put_transform(*, transform_id, dest=None, source=None, defer_validation=None, description=None, error_trace=None, filter_path=None, frequency=None, human=None, latest=None, meta=None, pivot=None, pretty=None, retention_policy=None, settings=None, sync=None, timeout=None, body=None)

    Create a transform. Creates a transform.

    A transform copies data from source indices, transforms it, and persists it into an entity-centric destination index. You can also think of the destination index as a two-dimensional tabular data structure (known as a data frame). The ID for each document in the data frame is generated from a hash of the entity, so there is a unique row per entity.

    You must choose either the latest or pivot method for your transform; you cannot use both in a single transform. If you choose to use the pivot method for your transform, the entities are defined by the set of `group_by` fields in the pivot object. If you choose to use the latest method, the entities are defined by the `unique_key` field values in the latest object.

    You must have `create_index`, `index`, and `read` privileges on the destination index and `read` and `view_index_metadata` privileges on the source indices. When Elasticsearch security features are enabled, the transform remembers which roles the user that created it had at the time of creation and uses those same roles. If those roles do not have the required privileges on the source and destination indices, the transform fails when it attempts unauthorized operations.

    NOTE: You must use Kibana or this API to create a transform. Do not add a transform directly into any `.transform-internal*` indices using the Elasticsearch index API. If Elasticsearch security features are enabled, do not give users any privileges on `.transform-internal*` indices. If you used transforms prior to 7.5, also do not give users any privileges on `.data-frame-internal*` indices.

    https://www.elastic.co/guide/en/elasticsearch/reference/8.17/put-transform.html

    Parameters:

      - transform_id (str) – Identifier for the transform. This identifier can contain lowercase alphanumeric characters (a-z and 0-9), hyphens, and underscores. It has a 64 character limit and must start and end with alphanumeric characters.

      - dest (Mapping[str, Any] | None) – The destination for the transform.

      - source (Mapping[str, Any] | None) – The source of the data for the transform.

      - defer_validation (bool | None) – When the transform is created, a series of validations occur to ensure its success. For example, there is a check for the existence of the source indices and a check that the destination index is not part of the source index pattern. You can use this parameter to skip the checks, for example when the source index does not exist until after the transform is created. The validations are always run when you start the transform, however, with the exception of privilege checks.

      - description (str | None) – Free text description of the transform.

      - frequency (str | Literal[-1] | ~typing.Literal[0] | None) – The interval between checks for changes in the source indices when the transform is running continuously. Also determines the retry interval in the event of transient failures while the transform is searching or indexing. The minimum value is 1s and the maximum is 1h.

      - latest (Mapping[str, Any] | None) – The latest method transforms the data by finding the latest document for each unique key.

      - meta (Mapping[str, Any] | None) – Defines optional transform metadata.

      - pivot (Mapping[str, Any] | None) – The pivot method transforms the data by aggregating and grouping it. These objects define the group by fields and the aggregation to reduce the data.

      - retention_policy (Mapping[str, Any] | None) – Defines a retention policy for the transform. Data that meets the defined criteria is deleted from the destination index.

      - settings (Mapping[str, Any] | None) – Defines optional transform settings.

      - sync (Mapping[str, Any] | None) – Defines the properties transforms require to run continuously.

      - timeout (str | Literal[-1] | ~typing.Literal[0] | None) – Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error.

      - error_trace (bool | None)

      - filter_path (str | Sequence[str] | None)

      - human (bool | None)

      - pretty (bool | None)

      - body (Dict[str, Any] | None)

    Return type:

      ObjectApiResponse[Any]

  reset_transform(*, transform_id, error_trace=None, filter_path=None, force=None, human=None, pretty=None)

    Reset a transform. Resets a transform. Before you can reset it, you must stop it; alternatively, use the `force` query parameter. If the destination index was created by the transform, it is deleted.

    https://www.elastic.co/guide/en/elasticsearch/reference/8.17/reset-transform.html

    Parameters:

      - transform_id (str) – Identifier for the transform. This identifier can contain lowercase alphanumeric characters (a-z and 0-9), hyphens, and underscores. It has a 64 character limit and must start and end with alphanumeric characters.

      - force (bool | None) – If this value is true, the transform is reset regardless of its current state. If it’s false, the transform must be stopped before it can be reset.

      - error_trace (bool | None)

      - filter_path (str | Sequence[str] | None)

      - human (bool | None)

      - pretty (bool | None)

    Return type:

      ObjectApiResponse[Any]

  schedule_now_transform(*, transform_id, error_trace=None, filter_path=None, human=None, pretty=None, timeout=None)

    Schedule a transform to start now. Instantly runs a transform to process data.

    If you _schedule_now a transform, it will process the new data instantly, without waiting for the configured frequency interval. After _schedule_now API is called, the transform will be processed again at now + frequency unless _schedule_now API is called again in the meantime.

    https://www.elastic.co/guide/en/elasticsearch/reference/8.17/schedule-now-transform.html

    Parameters:

      - transform_id (str) – Identifier for the transform.

      - timeout (str | Literal[-1] | ~typing.Literal[0] | None) – Controls the time to wait for the scheduling to take place

      - error_trace (bool | None)

      - filter_path (str | Sequence[str] | None)

      - human (bool | None)

      - pretty (bool | None)

    Return type:

      ObjectApiResponse[Any]

  start_transform(*, transform_id, error_trace=None, filter_path=None, from_=None, human=None, pretty=None, timeout=None)

    Start a transform. Starts a transform.

    When you start a transform, it creates the destination index if it does not already exist. The `number_of_shards` is set to `1` and the `auto_expand_replicas` is set to `0-1`. If it is a pivot transform, it deduces the mapping definitions for the destination index from the source indices and the transform aggregations. If fields in the destination index are derived from scripts (as in the case of `scripted_metric` or `bucket_script` aggregations), the transform uses dynamic mappings unless an index template exists. If it is a latest transform, it does not deduce mapping definitions; it uses dynamic mappings. To use explicit mappings, create the destination index before you start the transform. Alternatively, you can create an index template, though it does not affect the deduced mappings in a pivot transform.

    When the transform starts, a series of validations occur to ensure its success. If you deferred validation when you created the transform, they occur when you start the transform—​with the exception of privilege checks. When Elasticsearch security features are enabled, the transform remembers which roles the user that created it had at the time of creation and uses those same roles. If those roles do not have the required privileges on the source and destination indices, the transform fails when it attempts unauthorized operations.

    https://www.elastic.co/guide/en/elasticsearch/reference/8.17/start-transform.html

    Parameters:

      - transform_id (str) – Identifier for the transform.

      - from – Restricts the set of transformed entities to those changed after this time. Relative times like now-30d are supported. Only applicable for continuous transforms.

      - timeout (str | Literal[-1] | ~typing.Literal[0] | None) – Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error.

      - error_trace (bool | None)

      - filter_path (str | Sequence[str] | None)

      - from_ (str | None)

      - human (bool | None)

      - pretty (bool | None)

    Return type:

      ObjectApiResponse[Any]

  stop_transform(*, transform_id, allow_no_match=None, error_trace=None, filter_path=None, force=None, human=None, pretty=None, timeout=None, wait_for_checkpoint=None, wait_for_completion=None)

    Stop transforms. Stops one or more transforms.

    https://www.elastic.co/guide/en/elasticsearch/reference/8.17/stop-transform.html

    Parameters:

      - transform_id (str) – Identifier for the transform. To stop multiple transforms, use a comma-separated list or a wildcard expression. To stop all transforms, use _all or * as the identifier.

      - allow_no_match (bool | None) – Specifies what to do when the request: contains wildcard expressions and there are no transforms that match; contains the _all string or no identifiers and there are no matches; contains wildcard expressions and there are only partial matches. If it is true, the API returns a successful acknowledgement message when there are no matches. When there are only partial matches, the API stops the appropriate transforms. If it is false, the request returns a 404 status code when there are no matches or only partial matches.

      - force (bool | None) – If it is true, the API forcefully stops the transforms.

      - timeout (str | Literal[-1] | ~typing.Literal[0] | None) – Period to wait for a response when wait_for_completion is true. If no response is received before the timeout expires, the request returns a timeout exception. However, the request continues processing and eventually moves the transform to a STOPPED state.

      - wait_for_checkpoint (bool | None) – If it is true, the transform does not completely stop until the current checkpoint is completed. If it is false, the transform stops as soon as possible.

      - wait_for_completion (bool | None) – If it is true, the API blocks until the indexer state completely stops. If it is false, the API returns immediately and the indexer is stopped asynchronously in the background.

      - error_trace (bool | None)

      - filter_path (str | Sequence[str] | None)

      - human (bool | None)

      - pretty (bool | None)

    Return type:

      ObjectApiResponse[Any]

  update_transform(*, transform_id, defer_validation=None, description=None, dest=None, error_trace=None, filter_path=None, frequency=None, human=None, meta=None, pretty=None, retention_policy=None, settings=None, source=None, sync=None, timeout=None, body=None)

    Update a transform. Updates certain properties of a transform.

    All updated properties except `description` do not take effect until after the transform starts the next checkpoint, thus there is data consistency in each checkpoint. To use this API, you must have `read` and `view_index_metadata` privileges for the source indices. You must also have `index` and `read` privileges for the destination index. When Elasticsearch security features are enabled, the transform remembers which roles the user who updated it had at the time of update and runs with those privileges.

    https://www.elastic.co/guide/en/elasticsearch/reference/8.17/update-transform.html

    Parameters:

      - transform_id (str) – Identifier for the transform.

      - defer_validation (bool | None) – When true, deferrable validations are not run. This behavior may be desired if the source index does not exist until after the transform is created.

      - description (str | None) – Free text description of the transform.

      - dest (Mapping[str, Any] | None) – The destination for the transform.

      - frequency (str | Literal[-1] | ~typing.Literal[0] | None) – The interval between checks for changes in the source indices when the transform is running continuously. Also determines the retry interval in the event of transient failures while the transform is searching or indexing. The minimum value is 1s and the maximum is 1h.

      - meta (Mapping[str, Any] | None) – Defines optional transform metadata.

      - retention_policy (None | Mapping[str, Any]) – Defines a retention policy for the transform. Data that meets the defined criteria is deleted from the destination index.

      - settings (Mapping[str, Any] | None) – Defines optional transform settings.

      - source (Mapping[str, Any] | None) – The source of the data for the transform.

      - sync (Mapping[str, Any] | None) – Defines the properties transforms require to run continuously.

      - timeout (str | Literal[-1] | ~typing.Literal[0] | None) – Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error.

      - error_trace (bool | None)

      - filter_path (str | Sequence[str] | None)

      - human (bool | None)

      - pretty (bool | None)

      - body (Dict[str, Any] | None)

    Return type:

      ObjectApiResponse[Any]

  upgrade_transforms(*, dry_run=None, error_trace=None, filter_path=None, human=None, pretty=None, timeout=None)

    Upgrade all transforms. Transforms are compatible across minor versions and between supported major versions. However, over time, the format of transform configuration information may change. This API identifies transforms that have a legacy configuration format and upgrades them to the latest version. It also cleans up the internal data structures that store the transform state and checkpoints. The upgrade does not affect the source and destination indices. The upgrade also does not affect the roles that transforms use when Elasticsearch security features are enabled; the role used to read source data and write to the destination index remains unchanged.

    If a transform upgrade step fails, the upgrade stops and an error is returned about the underlying issue. Resolve the issue then re-run the process again. A summary is returned when the upgrade is finished.

    To ensure continuous transforms remain running during a major version upgrade of the cluster – for example, from 7.16 to 8.0 – it is recommended to upgrade transforms before upgrading the cluster. You may want to perform a recent cluster backup prior to the upgrade.

    https://www.elastic.co/guide/en/elasticsearch/reference/8.17/upgrade-transforms.html

    Parameters:

      - dry_run (bool | None) – When true, the request checks for updates but does not run them.

      - timeout (str | Literal[-1] | ~typing.Literal[0] | None) – Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error.

      - error_trace (bool | None)

      - filter_path (str | Sequence[str] | None)

      - human (bool | None)

      - pretty (bool | None)

    Return type:

      ObjectApiResponse[Any]