ElasticSearch关于索引库的命令操作

1.开集群

  (1)跳转到elasticsearch-head下运行npm run start命令

  (2)再开一个窗口连接,切换用户,切换到elasticsearch-6.2.3的bin下开启elasticsearch

2,再开一个窗口,进行索引库命令操作

 (1)创建索引库

curl -XPUT http://localhost:9200/index03

 

 (2)添加数据

 

 (3)更新数据

  

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","高端"]
}'

注意:使用完上面这个更新,再去使用其他方式更新会报错需要修改

  修改:切换到elasticsearch-6.2.3的config下,在elasticsearch.yml下添加代码

注意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'

猜你喜欢

转载自www.cnblogs.com/erci-520/p/9355949.html