PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, October 25, 2022

[FIXED] What are aliases in elasticsearch for?

 October 25, 2022     elasticsearch     No comments   

Issue

I recently started working in a company that uses Elasticsearch. While most of its concepts are somewhat similar to relational databases and I am able to understand them, I still don't quite get the concept of aliases.

I did not find any such question here and the information provided on the Elasticsearch website did not help much either.

Can someone explain what aliases are for and ideally include an example of a situation where they are needed?


Solution

@arhak covered the topic pretty well. One use case that (at least) made me understand the value of indices was the need to remove out-of-date documents and more specifically when using time-based-indices.

For example, you need to keep the logs of an application for at least one year. You decide to use time-based-indices, meaning you save into indices with the following format: 2018-02-logs, 2018-03-logs etc.. In order to be able to search in every index you create the following alias:

POST /_aliases
{
 "actions": [{ 
     "add": {
          "alias": "current-logs", "indices": [ "2018-02-logs","2018-03-logs" ]
        }  
  }]
}

And query like:

GET /current-logs/_search

Another advantage is that you can delete the out-of-date values very easily:

POST /_aliases
{
  "actions": [

      { "remove": { "alias": "current-logs",  "index": "logs_2018-01" }}
  ]
}

and DELETE /logs_2018-01



Answered By - Eirini Graonidou
Answer Checked By - Cary Denson (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing