• 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'

  • 相关阅读:
    Python中读取文件中的json串,并将其写入到Excel表格中
    Python中替换敏感字
    Python写一个批量生成账号的函数
    解决MySQL不允许远程连接的问题
    Jenkins安装与配置
    Jmeter监听tomcat
    onlyoffice document docker版安装使用总结
    onlyoffice-DocumentServer 的权限验证
    docker 部署es
    docker部署graylog使用教程
  • 原文地址:https://www.cnblogs.com/erci-520/p/9355949.html
Copyright © 2020-2023  润新知