Elasticsearch Alias


Elasticsearch Alias

Opster Team

Nov 2020


In addition to reading this guide, run the Elasticsearch Health Check-Up. Detect problems and improve performance by analyzing your shard sizes, threadpools, memory, snapshots, disk watermarks and many more.
Free tool that requires no installation with +1000 users.

 

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 an alias that is tied to 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, which 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



Improve Elasticsearch Performance

Run The Analysis