[0~4:12]
簡介:
- 一個分佈式,restful風格的搜索引擎
- 支持對各種數據類型的檢索
- 搜索速度快,可以提供實時的搜索服務
- 便於水平拓展,每秒處理PB級別的海量數據
術語:
索引、類型、文檔(json結構)、字段; 分別和MySQL的數據庫,表,一行或者一條數據,一列
集羣、節點、分片、副本;
集羣-》分佈式部署
分片是對索引進一步的劃分,副本是對分片的備份
es6.0 之後,廢棄了類型,一個索引就對應一張表
安裝:
Springboot中用的6.4.3;
中文分詞插件: ik解壓的時候必須解壓到elasticsearch下面plugins的ik的文件夾下,ik文件夾需要自己新建
postman:模擬網頁發送http請求
雙擊這個啓動es
curl -X GET "localhost:9200/_cat/health?v"
## 查看節點
curl -X GET "localhost:9200/_cat/nodes?v"
## 當前es服務器裏面的索引
curl -X GET "localhost:9200/_cat/indices?v"
## 創建索引
curl -X PUT "localhost:9200/test"
## 刪除索引
curl -X DELETE "localhost:9200/test"
Postman操作:
## 查詢索引
localhost:9200/_cat/indices?v
## 重建索引
put ---》 localhost:9200/test
## 刪除索引
Delete ---》》 localhost:9200/test
## 提交(修改)數據 test是索引;_doc是佔位,表示文檔類型;1是數據id
put ---》》 localhost:9200/test/_doc/1
寫在body裏面的:
{
"title":"hello",
"content":"how are you"
}
## 查數據
GET ---》 localhost:9200/test/_doc/1
## 刪數據
DELETE ---》 localhost:9200/test/_doc/1
## 搜索
GET --》 localhost:9200/test/_search
GET --》 localhost:9200/test/_search?q=title:互聯網
GET --》 localhost:9200/test/_search?q=content:運營實習
GET --》 localhost:9200/test/_search
body裏面(raw json)
{
"query":
{
"multi_match":
{
"query":"互聯網",
"fields":["title","content"]
}
}
}