ELK 設(shè)置定時清理腳本清理索引
634
2025-03-31
elasticsearch 支持 JSON 格式的操作數(shù)據(jù),它就是 DSL (Domain Specific Language),通過將查詢的 DSL 看待成 AST (Abstract Syntax Tree),其中包括葉子查詢子句(單一邏輯)及復合查詢子句(組合邏輯)。
以下操作都在 Kibana Dev Tools 中進行實踐。
索引(Index)
# 創(chuàng)建索引 PUT materiel { "settings" : { "number_of_shards" : 3, "number_of_replicas": 1 }, "mappings" : { "properties" : { "materiel" : { "type" : "text" }, "description" : { "type" : "text" } } } }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# 獲取索引信息 GET materiel
1
2
# 修改索引 Setting 中的 副本數(shù)量為 2 PUT materiel { "settings" : { "number_of_replicas": 2 } } ##### 刪除索引 ```json # 刪除索引 DELETE materiel
1
2
3
4
5
6
7
8
9
10
11
# 創(chuàng)建索引并手動指定ID,不指定時為隨機生成文檔ID POST materiel/_doc/1 { "materiel" : "10010001", "description" : "橙汁" }
1
2
3
4
5
6
# 創(chuàng)建索引并手動指定ID,不指定ID時會報錯 PUT materiel/_doc/2 { "materiel" : "10010002", "description" : "葡萄汁" }
1
2
3
4
5
6
# 指定ID獲取數(shù)據(jù) materiel/_doc/1
1
2
# 獲取全部索引中的文檔數(shù)據(jù) GET _search { "query": { "match_all": {} } }
1
2
3
4
5
6
7
# 獲取索引全部數(shù)據(jù) GET materiel/_search { "query": { "match_all": {} } }
1
2
3
4
5
6
7
# 同時 POST 方法也適用用于獲取全部數(shù)據(jù) POST materiel/_search { "query": { "match_all": {} } }
1
2
3
4
5
6
7
# POST 已存在的 ID 則為更新數(shù)據(jù),否則為創(chuàng)建文檔 POST materiel/_doc/1 { "materiel" : "10010001", "description" : "西瓜汁" }
1
2
3
4
5
6
# PUT 已存在的 ID 則為更新數(shù)據(jù),否則為提示失敗 PUT materiel/_doc/2 { "materiel" : "10010002", "description" : "青瓜汁" }
1
2
3
4
5
6
# 根據(jù) ID 刪除對應(yīng)的文檔 DELETE materiel/_doc/1
1
2
版權(quán)聲明:本文內(nèi)容由網(wǎng)絡(luò)用戶投稿,版權(quán)歸原作者所有,本站不擁有其著作權(quán),亦不承擔相應(yīng)法律責任。如果您發(fā)現(xiàn)本站中有涉嫌抄襲或描述失實的內(nèi)容,請聯(lián)系我們jiasou666@gmail.com 處理,核實后本網(wǎng)站將在24小時內(nèi)刪除侵權(quán)內(nèi)容。
版權(quán)聲明:本文內(nèi)容由網(wǎng)絡(luò)用戶投稿,版權(quán)歸原作者所有,本站不擁有其著作權(quán),亦不承擔相應(yīng)法律責任。如果您發(fā)現(xiàn)本站中有涉嫌抄襲或描述失實的內(nèi)容,請聯(lián)系我們jiasou666@gmail.com 處理,核實后本網(wǎng)站將在24小時內(nèi)刪除侵權(quán)內(nèi)容。