ES命令基礎


切換至ES根目錄運行  npm run start啟動服務     輸入網址:ip地址:9100   檢查是否啟動成功

新建會話:切換至非root用戶cd到es的根目錄下的bin執行./elasticsearch

創建索引: curl -XPUT http://localhost:9200/zy2index

查看索引庫: curl -XGET http://localhost:9200/_cat/indices?v

插入數據:

curl -H "Content-Type: application/json" -XPUT http://localhost:9200/zy2index/product/p1 -d '{
"name":"mac",
"price":20000,
"description":"蘋果筆記本",
"attr":["computer","高端"]
}'

如果編號沖突,默認后保存的直接覆蓋之前的數據

方法一:

curl -H "Content-Type: application/json" -XPUT http://localhost:9200/zy2index/product/p1?op_type=create -d '{
"name":"mac",
"price":20000,
"description":"蘋果筆記本",
"attr":["computer","高端"]
}'

方法二

curl -H "Content-Type: application/json" -XPUT http://localhost:9200/zy2index/product/p1/_create -d '{
"name":"mac",
"price":20000,
"description":"蘋果筆記本",
"attr":["computer","第端"]
}'

 

查詢:  curl -XGET http://localhost:9200/zy2index/product/p1?pretty

_source中是數據,只看數據命令:  curl -XGET http://localhost:9200/zy2index/product/p1?_source=name,price\&pretty

修改數據:

curl -H "Content-Type: application/json" -XPOST http://localhost:9200/zy2index/product/p1/_update?pretty -d '{"doc":
{"name":"mac第四次",
"price":2000,
"description":"蘋果筆記本",
"attr":["computer","高端"]}
}'

刪除數據  

curl -H "Content-Type: application/json" -XPUT http://192.168.8.128:9200/zy2index/product/p3 -d '{
"name":"mac第四次",
"price":2000,
"description":"蘋果筆記本",
"attr":["computer","高端"]
}'

刪除索引:  curl -XDELETE http://192.168.8.128:9200/zy2index/product/p1?pretty

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM