当前位置:网站首页>What is the use of index aliases in ES
What is the use of index aliases in ES
2022-06-26 13:32:00 【Elastic open source community】
List of articles
1、 Alias (alias) What is it?
1.1 The official definition of
According to my habit , First give the official answer The index alias The definition of : An index alias is a secondary name used to reference one or more existing indexes . majority Elasticsearch API Accept index aliases instead of indexes .
1.2 Popular explanation
Official explanations are generally difficult to understand , This is especially true for people who have not touched or used it . Many online explanations say that the index alias is to protect the index , You can hide the index relative to the caller . In fact, this explanation can only be understood by people who understand what alias is , And those who understand it disdain to read it
In fact, the index alias is another name bound to the index , An alias can bind multiple indexes , An index can also be bound to multiple aliases . As for the function and significance of the index , I will use the following example to explain . Remember the conclusion first : Index aliases are very common 、 Very, very important .
2、 Alias (alias) What's the use
2.1 Analogy to the role of domain names
Before explaining the alias , Think about it first , What is the use of our common domain names ?
2.1.1 Than IP Good record
such as www.baidu.com, Than 110.242.68.4 Much easier to remember .
2.1.2 You can bind multiple IP Or applications
such as :
2.1.3 DNS Load balancing
Generally speaking , It is impossible for a web service to have only one server , It is a highly available cluster composed of multiple servers , High availability clusters often need to be load balanced , Such as Nginx、LVS etc. .
But with the increasing number of user requests , Load balancing also reaches the performance limit , It is necessary to solve the problem from the source , That is to say DNS distribution , Or call it DNS Load balancing .
that DNS How to forward the request ? Let's take a look at how a user's request is sent to the server 
Suppose the server of a website is in Beijing , So users in Shanghai want to get the data on the server , It takes a long distance , Due to transmission speed, routing and forwarding, etc , It will cause the access speed to be very slow .
Therefore, many large Internet companies will deploy multiple data centers nationwide or even worldwide , Users in different regions only need to DNS Forward user request , Visit nearby , In this way, the speed increases a lot . This process is from the source of the user request 
such as , When I am from where I am ( Beijing ) When visiting Baidu's domain name ,DNS Point to me IP The address is :110.242.68.4
When I access Baidu domain name from a remote host , Of the returned result IP The address is different .
2.2 The function of aliases
2.2.1 Hide the underlying index
Understand the role of domain name , Alias is easy to explain , stay ES in , The function of index alias is very similar to that of domain name , Aliases can be bound to multiple indexes , The client can call the index by calling the alias , In this way, if all changes in the underlying index are imperceptible to the user . The caller does not know which indexes the index alias refers to , And don't care .
2.2.2 Encapsulated filter
For example, the following code pairs the index test Created two aliases , among , When calling alias_2 When executing a query on an index , The filter that will automatically execute the do not hit
PUT /test
{
"aliases": {
"alias_1": {
},
"alias_2": {
"filter": {
"term": {
"user.id": "kimchy" }
}
}
}
}
When an index often needs to execute certain specific queries , You can define... In this way . For example, yes. person The index defines three aliases , People of different ages can be queried without adding any query criteria :
- person_lt_18
- person_lt_30
- person_gte_30
3、 Alias (alias) Where to use : Use scenarios
3.1 Scroll index

3.2 Index template / Component template
PUT _index_template/my_template
{
"index_patterns": ["test_ilm_index_*"],
"template": {
"settings": {
"number_of_shards": 1,
"number_of_replicas": 0,
"index.lifecycle.name": "test_ilm"
}
}
}
3.3 Data flow
Convert index aliases to data streams
POST /_data_stream/_migrate/<alias>
4、 Alias (alias) How to use it?
4.1 grammar
POST /_aliases
4.2 Basic usage
4.2.1 Add an alias to the index
to product Add alias product_template
POST _aliases
{
"actions" : [
{
"add" : {
"index" : "product", "alias" : "product_template" } }
]
}
4.2.2 Alias the index
hold product Rename the alias of to product_real ( Atomic manipulation )
POST /_aliases
{
"actions" : [
{
"remove" : {
"index" : "product", "alias" : "product_template" } },
{
"add" : {
"index" : "product", "alias" : "product_real" } }
]
}
4.2.3 Unbind alias for index
Delete product Another name for product_real
POST /_aliases
{
"actions" : [
{
"remove" : {
"index" : "product", "alias" : "product_real" } }
]
}
4.2.4 Bind multiple aliases
One alias binds to multiple indexes
POST /_aliases
{
"actions" : [
{
"add" : {
"index" : "product", "alias" : "product_real2" } },
{
"add" : {
"index" : "product2", "alias" : "product_real2" } }
]
}
4.2.5 Bind alias when defining index
Specify alias when defining index mapping
PUT /test
{
"aliases": {
"alias_1": {
},
"alias_2": {
"filter": {
"term": {
"user.id": "kimchy" }
}
}
}
}
4.2.6 As field type
PUT trips
{
"mappings": {
"properties": {
"distance": {
"type": "long"
},
"route_length_miles": {
"type": "alias",
"path": "distance"
},
"transit_mode": {
"type": "keyword"
}
}
}
}
GET _search
{
"query": {
"range" : {
"route_length_miles" : {
"gte" : 39
}
}
}
}
边栏推荐
- IDC report: the AI cloud market share of Baidu AI Cloud ranks first for six consecutive times
- Beifu cx5130 card replacement and transfer of existing authorization files
- What features are added to Photoshop 2022 23.4.1? Do you know anything
- 组合模式(Composite )
- code force Party Lemonade
- C - Common Subsequence
- Sed editor
- H5 video automatic playback and circular playback
- There are many contents in the widget, so it is a good scheme to support scrolling
- 7-1 range of numbers
猜你喜欢

适配器模式(Adapter)

Arcpy——InsertLayer()函數的使用:摻入圖層到地圖文檔裏

Input text to automatically generate images. It's fun!

Beifu realizes the control of time slice size and quantity through CTU and ton

Nexys A7开发板资源使用技巧

Stack, LIFO
![8. [STM32] timer (TIM) -- interrupt, PWM, input capture experiment (proficient in timer)](/img/e7/2fd8ec8d5e5473c7f84f3e3bcedca8.png)
8. [STM32] timer (TIM) -- interrupt, PWM, input capture experiment (proficient in timer)

网络远程访问的方式使用树莓派

MariaDB study notes
![Hdu1724[Simpson formula for integral]ellipse](/img/57/fb5098e150b5f3d91a5d0983a336ee.png)
Hdu1724[Simpson formula for integral]ellipse
随机推荐
MySQL数据库讲解(六)
Custom encapsulation drop-down component
【Proteus仿真】Arduino UNO按键启停 + PWM 调速控制直流电机转速
偶言佳句,孤芳自赏
Learn how to develop owl components by hand (7): practical use of owl projects
KITTI Tracking dataset whose format is letf_ top_ right_ bottom to JDE normalied xc_ yc_ w_ h
HDU 3555 Bomb
E - Apple Catching
Uva5009 error curves three points
Arcpy -- use of insertlayer() function: adding layers to map documents
ES基於Snapshot(快照)的數據備份和還原
Stack, LIFO
A few lines of code can realize complex excel import and export. This tool class is really powerful!
[how to connect the network] Chapter 2 (middle): sending a network packet
What features are added to Photoshop 2022 23.4.1? Do you know anything
Analysis of state transition diagram of Beifu NC axis
Detailed sorting of HW blue team traceability process
KITTI Detection dataset whose format is letf_ top_ right_ bottom to JDE normalied xc_ yc_ w_ h
Update and download of Beifu EtherCAT XML description file
三维向量的夹角