Create or update trained model aliases API
Creates or updates a trained model alias.
A trained model alias is a logical name used to reference a single trained model.
Request
PUT _ml/trained_models/<model_id>/model_aliases/<model_alias>
Prerequisites
Requires the manage_ml cluster privilege. This privilege is included in the machine_learning_admin built-in role.
Description
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.
API Restrictions:
- You are not allowed to update an alias such that it references a different trained model ID and the model uses a different type of data frame analytics. 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.
- You cannot update an alias from a
pytorchmodel and a data frame analytics model. - You cannot update the alias from a deployed
pytorchmodel to one not currently deployed.
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 parameters
-
model_alias - (Required, string) The alias to create or update. This value cannot end in numbers.
-
model_id - (Required, string) The identifier for the trained model that the alias refers to.
Query parameters
-
reassign - (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 tofalse.
Examples
Create a trained model alias
The following example shows how to create an alias (flight_delay_model) for a trained model (flight-delay-prediction-1574775339910):
resp = client.ml.put_trained_model_alias(
model_id="flight-delay-prediction-1574775339910",
model_alias="flight_delay_model",
)
print(resp) response = client.ml.put_trained_model_alias( model_id: 'flight-delay-prediction-1574775339910', model_alias: 'flight_delay_model' ) puts response
const response = await client.ml.putTrainedModelAlias({
model_id: "flight-delay-prediction-1574775339910",
model_alias: "flight_delay_model",
});
console.log(response); PUT _ml/trained_models/flight-delay-prediction-1574775339910/model_aliases/flight_delay_model
Update a trained model alias
The following example shows how to reassign an alias (flight_delay_model) to a different trained model (flight-delay-prediction-1580004349800):
resp = client.ml.put_trained_model_alias(
model_id="flight-delay-prediction-1580004349800",
model_alias="flight_delay_model",
reassign=True,
)
print(resp) response = client.ml.put_trained_model_alias( model_id: 'flight-delay-prediction-1580004349800', model_alias: 'flight_delay_model', reassign: true ) puts response
const response = await client.ml.putTrainedModelAlias({
model_id: "flight-delay-prediction-1580004349800",
model_alias: "flight_delay_model",
reassign: "true",
});
console.log(response); PUT _ml/trained_models/flight-delay-prediction-1580004349800/model_aliases/flight_delay_model?reassign=true
© 2023-2025 Elasticsearch
As of September 2024, Elasticsearch is available under a choice of three licenses: the Server Side Public License (SSPL), the Elastic License, or the AGPLv3 (OSI approved).
Elasticsearch and the Elasticsearch logo are trademarks of Elasticsearch B.V., registered in the U.S. and in other countries.
https://www.elastic.co/guide/en/elasticsearch/reference/8.17/put-trained-models-aliases.html