日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

ES 基本操作

發布時間:2025/3/11 编程问答 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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

總結

以上是生活随笔為你收集整理的ES 基本操作的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。