Create or update an alias Generally available; Added in 1.3.0

POST /_aliases

Adds a data stream or index to an alias.

Query parameters

  • master_timeout string

    Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error.

    Values are -1 or 0.

    External documentation
  • timeout string

    Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error.

    Values are -1 or 0.

    External documentation
application/json

Body Required

  • actions array[object]

    Actions to perform.

    Hide actions attributes Show actions attributes object
    • add object

      Adds a data stream or index to an alias. If the alias doesn’t exist, the add action creates it.

      Hide add attributes Show add attributes object
      • alias string

        Alias for the action. Index alias names support date math.

      • aliases string | array[string]

        Aliases for the action. Index alias names support date math.

      • filter object

        Query used to limit documents the alias can access.

        External documentation
        Hide filter attributes Show filter attributes object
        • common object Deprecated
        • fuzzy object

          Returns documents that contain terms similar to the search term, as measured by a Levenshtein edit distance.

        • geo_grid object

          Matches geo_point and geo_shape values that intersect a grid cell from a GeoGrid aggregation.

        • intervals object

          Returns documents based on the order and proximity of matching terms.

        • match object

          Returns documents that match a provided text, number, date or boolean value. The provided text is analyzed before matching.

        • match_bool_prefix object

          Analyzes its input and constructs a bool query from the terms. Each term except the last is used in a term query. The last term is used in a prefix query.

        • match_phrase object

          Analyzes the text and creates a phrase query out of the analyzed text.

        • match_phrase_prefix object

          Returns documents that contain the words of a provided text, in the same order as provided. The last term of the provided text is treated as a prefix, matching any words that begin with that term.

        • prefix object

          Returns documents that contain a specific prefix in a provided field.

        • range object

          Returns documents that contain terms within a provided range.

        • regexp object

          Returns documents that contain terms matching a regular expression.

        • span_term object

          Matches spans containing a term.

        • term object

          Returns documents that contain an exact term in a provided field. To return a document, the query term must exactly match the queried field's value, including whitespace and capitalization.

        • terms_set object

          Returns documents that contain a minimum number of exact terms in a provided field. To return a document, a required number of terms must exactly match the field values, including whitespace and capitalization.

        • text_expansion object Deprecated Generally available; Added in 8.8.0

          Uses a natural language processing model to convert the query text into a list of token-weight pairs which are then used in a query against a sparse vector or rank features field.

        • weighted_tokens object Deprecated Generally available; Added in 8.13.0

          Supports returning text_expansion query results by sending in precomputed tokens with the query.

        • wildcard object

          Returns documents that contain terms matching a wildcard pattern.

      • index string

        Data stream or index for the action. Supports wildcards (*).

      • indices string | array[string]

        Data streams or indices for the action. Supports wildcards (*).

      • index_routing string

        Value used to route indexing operations to a specific shard. If specified, this overwrites the routing value for indexing operations. Data stream aliases don’t support this parameter.

      • is_hidden boolean

        If true, the alias is hidden.

        Default value is false.

      • is_write_index boolean

        If true, sets the write index or data stream for the alias.

      • routing string

        Value used to route indexing and search operations to a specific shard. Data stream aliases don’t support this parameter.

      • search_routing string

        Value used to route search operations to a specific shard. If specified, this overwrites the routing value for search operations. Data stream aliases don’t support this parameter.

      • must_exist boolean

        If true, the alias must exist to perform the action.

        Default value is false.

    • remove object

      Removes a data stream or index from an alias.

      Hide remove attributes Show remove attributes object
      • alias string

        Alias for the action. Index alias names support date math.

      • aliases string | array[string]

        Aliases for the action. Index alias names support date math.

      • index string

        Data stream or index for the action. Supports wildcards (*).

      • indices string | array[string]

        Data streams or indices for the action. Supports wildcards (*).

      • must_exist boolean

        If true, the alias must exist to perform the action.

        Default value is false.

    • remove_index object

      Deletes an index. You cannot use this action on aliases or data streams.

      Hide remove_index attributes Show remove_index attributes object
      • index string

        Data stream or index for the action. Supports wildcards (*).

      • indices string | array[string]

        Data streams or indices for the action. Supports wildcards (*).

      • must_exist boolean

        If true, the alias must exist to perform the action.

        Default value is false.

Responses

  • 200 application/json
    Hide response attribute Show response attribute object
    • acknowledged boolean Required

      For a successful response, this value is always true. On failure, an exception is returned instead.

POST /_aliases
curl \
 --request POST 'http://api.example.com/_aliases' \
 --header "Content-Type: application/json" \
 --data '"{\n  \"actions\": [\n    {\n      \"add\": {\n        \"index\": \"logs-nginx.access-prod\",\n        \"alias\": \"logs\"\n      }\n    }\n  ]\n}"'
Request example
An example body for a `POST _aliases` request.
{
  "actions": [
    {
      "add": {
        "index": "logs-nginx.access-prod",
        "alias": "logs"
      }
    }
  ]
}