Elasticsearch Alias

Avoid the Next Incident

Check if your ES issues are caused from misconfigured settings

2-min process

Stop Elasticsearch settings related incidents :  Fix My Settings

Last Update: February 2020

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.

About Opster

Incorporating deep knowledge and broad history of Elasticsearch issues. Opster solution identifies and predicts root causes of Elasticsearch problems, provides recommendations and can automatically perform various actions to manage, troubleshoot and prevent issues

Learn more: Glossary | Blog| Troubleshooting guides

Need help with any Elasticsearch issue ? Contact Opster

Avoid the next incident use our settings check-up : Prevent Issues


Click below to learn how to fix common problems related to these concepts
« Back to Index