ES 基本操作
0.查看集群是否健康
GET /_cluster/health
1.查詢所有索引
GET /_cat/indices?v
?
2.查詢單個索引的映射
GET /index_trans_detail/_mapping
3.刪除index
DELETE /index_trans_detail,index_two
4. 添加字段映射
PUT /index_trans_detail/_mapping/type_trans_detail
{
"properties": {
"tags":{
"type": "text"
}
}
}
5. 索引的別名
5.1 創建索引的別名
PUT /index_trans_detail/_alias/index_trans_detail_alias
5.2 查詢索引的別名
GET /index_trans_detail/_alias/*
5.3 查詢別名指向哪一個索引
GET /*/_alias/index_trans_detail_alias
5.4 刪除別名
DELETE /index_trans_detail/_alias/index_trans_detail_alias
6. 添加一個索引(通過mapping)
PUT /people
{
? "settings": {
? ? "number_of_shards": 3,
? ? "number_of_replicas": 1
? },
? "mappings": {
? ? "man": {
? ? ? "dynamic": "strict",
? ? ? "properties": {
? ? ? ? "name": {
? ? ? ? ? "type": "text"
? ? ? ? },
? ? ? ? "age": {
? ? ? ? ? "type": "integer"
? ? ? ? },
? ? ? ? "birthday": {
? ? ? ? ? "type": "date",
? ? ? ? ? "format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
? ? ? ? },
? ? ? ? "address":{
? ? ? ? ? "dynamic": "true",
? ? ? ? ? "type": "object"
? ? ? ? }
? ? ? }
? ? }
? }
}
"dynamic": "strict"? 表示如果遇到陌生field會報錯
"dynamic": "true"? ?表示如果遇到陌生字段,就進行dynamic mapping
"dynamic": "false"? ?表示如果遇到陌生字段,就忽略
?
7.修改字段可以排序
PUT index_trans_detail/_mapping/activity_dictionary
{
"properties": {
"type_code":{
"type": "text",
"fielddata": true
}
}
}
7.1 添加字段
PUT /index_trans_detail/_mapping/type_trans_detail
{
"properties": {
"tags":{
"type": "text"
}
}
}
?
通過別名更換索引
==========================================================
8.創建別名
POST _aliases
{
"actions": [
{
"add": {
"index": "old_index",
"alias": "old_index_alias"
}
}
]
}
9.將老的索引中的數據復制到新的索引中:
POST _reindex
{
"source": {
"index": "old_index"(老的索引名)
},
"dest": {
"index": "new_index"(新的索引名)
}
}
10,創建映射
POST _aliases
{
"actions": [
{
"remove": {
"index": "old_index",
"alias": "old_index_alias"
}},
{
"add": {
"index": "new_index",
"alias": "old_index_alias"
}
}
]
}
11.刪除舊索引
DELETE old_index
轉載于:https://www.cnblogs.com/zeenzhou/p/11588629.html
總結
- 上一篇: JDBC中使用RowSet包装结果集
- 下一篇: 春晓JAVA的横排和竖排输出