Create or update trained model aliases APIedit

Creates or updates a trained model alias.

A trained model alias is a logical name used to reference a single trained model.


PUT _ml/trained_models/<model_id>/model_aliases/<model_alias>


If the Elasticsearch security features are enabled, you must have the following built-in role:

  • machine_learning_admin

For more information, see Built-in roles, Security privileges, and Machine learning security privileges.


You can use aliases instead of trained model identifiers to make it easier to reference your models. For example, you can use aliases in inference aggregations and processors.

An alias must be unique and refer to only a single trained model. However, you can have multiple aliases for each trained model.

If you use this API to update an alias such that it references a different trained model ID and the model uses a different type of data frame analytics, an error occurs. For example, this situation occurs if you have a trained model for regression analysis and a trained model for classification analysis; you cannot reassign an alias from one type of trained model to another.

If you use this API to update an alias and there are very few input fields in common between the old and new trained models for the model alias, the API returns a warning.

Path parametersedit

(Required, string) The alias to create or update. This value cannot end in numbers.
(Required, string) The identifier for the trained model that the alias refers to.

Query parametersedit

(Optional, boolean) Specifies whether the alias gets reassigned to the specified trained model if it is already assigned to a different model. If the alias is already assigned and this parameter is false, the API returns an error. Defaults to false.


Create a trained model aliasedit

The following example shows how to create an alias (flight_delay_model) for a trained model (flight-delay-prediction-1574775339910):

PUT _ml/trained_models/flight-delay-prediction-1574775339910/model_aliases/flight_delay_model

Update a trained model aliasedit

The following example shows how to reassign an alias (flight_delay_model) to a different trained model (flight-delay-prediction-1580004349800):

PUT _ml/trained_models/flight-delay-prediction-1580004349800/model_aliases/flight_delay_model?reassign=true