1.上編寫到怎樣安裝部署elk,這篇記錄怎樣簡單使用。以便於后期復習使用。
2.登錄localhost:5601進入開發者模式。
3.初學擔心沒有數據可以自己PUT數據比較直觀的學習語法。這里可以用網上的開源數據。比如shakespeare.json accounts.json等數據源
4.導入數據在服務器上導入用curl -H "Content-Type: application/json" -XPOST 'localhost:9200/shak/account/_bulk?pretty' --data-binary "@/home/jx/shakespeare.json" 導入失敗之類
一般是因為沒有加-H條件。
5.查找
5.1一般查找 GET /shakespeare
5.2條件查找
GET /shakespeare/_search
{ "query": { "match": { "text_entry": "No more the thirsty entrance of this soil" } }, "sort": [ { "line_id": "desc" } ] }
5.3過濾查找
GET /shakespeare/_search { "query": { "bool": { "must": { "match": { "text_entry": "like" } }, "filter": { "range": { "line_id": { "gt": "50" } } } } } }
注意:要理解數據字段的意思和數據庫的思維一樣
5.4全文檢索某個字段包含某個關鍵字
GET /shakespeare/_search { "query": { "match": { "text_entry": "echo" } } }
5.5全文短語檢索
GET /shakespeare/_search { "query": { "match_phrase": { "text_entry": "of the" } } }
5.6
GET /shakespeare/_search { "query": { "bool": { "must": [ { "match": { "text_entry": "like" } } ], "should": [ { "match": { "speaker": "ORLANDO" } } ], "must_not": [ { "match": { "gt": "10000" } } ], "minimum_should_match": 1 } } }
注意:操作都在開發工具里完成。
5.7 基礎語法
查看數據狀態:GET localhost:9200/_cat/indices
查看某個數據狀態: GET localhost:9200/shakespeare
查看es狀態: GET localhost:9200
查看所有索引 : GET 10.2.15.232:9200/_cat