Elasticsearch Alias



Elasticsearch Alias

Opster Team

July 2020, Version: 1.7-8.0


Before you begin reading the explanation below, try running the free ES Health Check-Up get actionable recommendations that can improve Elasticsearch performance and prevent serious incidents. Just 2 minutes to complete and you can check your threadpools, memory, snapshots and many more

 

Alias in Elasticsearch

 

In Elasticsearch, an alias is a secondary name to refer to one or more indices. Aliases can be created and removed dynamically using _aliases REST endpoint.

What it is used for

Aliases are used for multiple purposes such as to search across more than one index with a single name, perform the reindexing process with zero downtime and query data based on predefined filters.

 

Examples

Creating an alias on a single index:

POST /_aliases?pretty
{
  "actions": [
    {
      "add": {
        "index": "index_1",
        "alias": "alias_1"
      }
    }
  ]
}

Creating the same alias on more than one index:

POST /_aliases?pretty
{
  "actions": [
    {
      "add": {
        "index": "index_1",
        "alias": "alias_1"
      }
    },
    {
      "add": {
        "index": "index_2",
        "alias": "alias_1"
      }
    }
  ]
}

Creating a filter-based alias:

POST /_aliases?pretty
{
  "actions": [
    {
      "add": {
        "index": "index_1",
        "alias": "alias_2",
        "filter": {
          "term": {
            "organization": "opster"
          }
        }
      }
    }
  ]
}

Listing out all of the available aliases in an Elasticsearch cluster:

GET _cat/aliases

Removing an alias:

POST /_aliases?pretty
{
  "actions": [
    {
      "remove": {
        "index": "index_2",
        "alias": "alias_1"
      }
    }
  ]
}
Notes
  • An Alias cannot be used for the indexing process if it points to more than one index. If attempted, Elasticsearch will throw an exception.
  • Deleting an alias does not delete the actual index.
Common Problems
  • Since a single alias can be attached to multiple indices, it is important to keep in mind that querying an alias will send the query against all the associated indices and this can impact the search performance and high resource utilization.

Related log errors to this ES concept


Ignoring dangled index on node due to an existing alias with the same name
Error creating ML annotations index or aliases
Created ML annotations index and aliases
Failed to temporary create in order to apply alias action
Failed to add alias . filter
Created alias for deprecated data frame notifications index
Error creating alias for deprecated data frame notifications index
Failed to start working on role alias permisssion deprecation messages
Index was already rolled over for alias . not attempting to roll over again
Unexpected IndexOrAlias for

About Opster

Opster detects, prevents, optimizes and automates everything needed to run mission-critical Elasticsearch

Find Configuration Errors

Analyze Now