1.開集羣npm
(1)跳轉到elasticsearch-head下運行npm run start命令json
(2)再開一個窗口鏈接,切換用戶,切換到elasticsearch-6.2.3的bin下開啓elasticsearchapp
2,再開一個窗口,進行索引庫命令操做curl
(1)建立索引庫elasticsearch
curl -XPUT http://localhost:9200/index03
(2)添加數據url
(3)更新數據3d
Content-Type:
curl -H "Content-Type: application/json" -XPUT http://192.168.153.4:9200/index02product/p1 -d '{
"name":"mac第一次",
"price":20000,
"description":"蘋果筆記本",
"attr":["computer","高端"]
}'blog
注意:使用完上面這個更新,再去使用其餘方式更新會報錯須要修改索引
修改:切換到elasticsearch-6.2.3的config下,在elasticsearch.yml下添加代碼ip
注意true 和false前面有空格
(4)刪除數據
curl -H "Content-Type: application/json" -XPUT http://192.168.153.4:9200/index02/product/p2 -d '{
"name":"風扇",
"price":2000,
"description":"充電小電扇",
"attr":["便攜式","體積小"]
}'
(5)刪除索引
curl -XDELETE http://192.168.153.4:9200/index02/product/p1?pretty
(6)查詢索引
curl -XGET http://192.168.153.4:9200/_cat/indices?v
(7)簡單查詢
curl -XGET 'http://192.168.153.4:9200/index02/product/_search?q=name:mac第一次&q=price:2000&pretty'
(8)分頁查詢
curl -XGET 'http://192.168.153.4:9200/index02/product/_search?size=2&from=2&pretty'