zoukankan      html  css  js  c++  java
  • 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'

  • 相关阅读:
    【转载】分布式环境Raft一致性共识算法解读
    从码农到工程师:只要做到这6点
    产品思维的修炼–技术的必修课
    工具篇
    安全测试
    测试体会
    测试题目
    软件测试工具
    常见的性能测试方法
    性能测试在软件测试的周期位置
  • 原文地址:https://www.cnblogs.com/erci-520/p/9355949.html
Copyright © 2011-2022 走看看