ElasticSearch 弹性设计
- ElasticSearch 索引别名
- ElasticSearch 属性别名
- ElasticSearch ingest
- 参考文献
版本信息:7.13.4
ElasticSearch 索引别名
索引别名
根据索引api创建别名
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30# 删除索引
DELETE my-index-000001
# 索引别名
PUT my-index-0000001
{
"aliases": {
"my-index": {}
}
}
# 创建索引
POST my-index/_doc
{
"name":"my-index"
}
# 根据索引查询数据
GET my-index/_search
# 原索引创建索引
POST my-index-0000001/_doc
{
"name":"mymy-index-0000001"
}
# 原索引查询
GET my-index-0000001/_search
# 索引别名信息查询
GET my-index-0000001/_alias
# 删除索引别名
DELETE my-index-0000001/_alias/my-index
# 添加索引别名
POST my-index-0000001/_alias/my-index_alias
创建别名is_write_index
控制是否可以写数据,默认是truerouting
路由配置别名(分片别名),可以分为search_routing
和index_routing
filter
条件别名,根据条件设置对应的别名查询
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98# 别名是否存在
HEAD _alias/my-index
# 查询别名使用的索引
GET _alias/my-index
# 别名api添加
POST _aliases
{
"actions": [
{
"add": {
"index": "my-index-0000001",
"alias": "my-index-01"
}
}
]
}
# 别名上的别名是不可以的,报错
POST _aliases
{
"actions": [
{
"add": {
"index": "my-index-01",
"alias": "my-index-02"
}
}
]
}
# 删除别名
POST _aliases
{
"actions": [
{
"remove": {
"index": "my-index-0000001",
"alias": "my-index-01"
}
}
]
}
# 读索引别名,不支持写索引操作
POST _aliases
{
"actions": [
{
"add": {
"index": "my-index-0000001",
"alias": "my-read-index",
"is_write_index":false
}
}
]
}
# 只读,不可以写数据
POST my-read-index/_doc
{
"name":"my-read-index"
}
# 可以查询
GET my-read-index/_search
# 根据路由创建分片别名
POST _aliases
{
"actions": [
{
"add": {
"index": "my-index-0000001",
"alias": "my-routing-index",
"routing": "1"
}
}
]
}
# 查询数据
GET my-routing-index/_search
# 根据filter 条件创建别名
POST _aliases
{
"actions": [
{
"add": {
"index": "my-index-0000001",
"alias": "my-filter-index",
"filter": {
"match": {
"name": "0000001"
}
}
}
}
]
}
# 查询数据
GET my-filter-index/_search
滚动别名
索引名称为6位数字结尾并用0左填充,比如
my-index-000001
查询参数
dry_run
检查是否已经触发条件了但是没有滚动,默认为falsewait_for_active_shards
操作的分片数,默认为1
请求体参数
aliases
支持多个别名,路由、条件过滤、是否读写conditions
条件判断滚动max_age
最大时间max_doc
最大文档max_size
最大大小max_primary_shard_size
主分片大小
mappings
属性设置settings
索引设置
1 |
|
ElasticSearch 属性别名
alias
别名
1 |
|
runtime
类型
使用emit方法进行执行,只支持
boolean
、date
、double
、geo_point
、ip
、keyword
、long
1 |
|
ElasticSearch ingest
- 可以设置
_source
里面的数据,- 可以设置
_index
、_id
、_routing
、_dynamic_templates
,注意要是自动创建ID的话,会失败(由于pipeline执行在创建索引ID之前)- 可以设置ingest里面的数据,目前只有
_ingest.timestamp
set
设置值remove
删除某个属性drop
根据条件删除文档rename
重命名date
时间转换
利用pipeline参数执行
1 |
|
设置索引pipeline
default_pipeline
默认的pipeline,没有pipeline的时候执行final_pipeline
最后执行的pipeline
1 |
|
参考文献
ElasticSearch 弹性设计
http://example.com/2021/08/05/ElasticSearch/ElasticSearch 弹性设计/