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'

  • 相关阅读:
    linux:centOs7换源阿里云
    nginx:负载均衡实战(一)
    linux-安装jdk以及tomcat
    nginx:在linux上进行nginx的安装
    开源 免费 java CMS
    使用PHP获取汉字的拼音(全部与首字母)
    php版获取重定向后地址的代码分享
    php获取数组中重复数据的两种方法
    php删除html标签的三种解决方法
    php curl 伪造IP来源的代码分享
  • 原文地址:https://www.cnblogs.com/erci-520/p/9355949.html
Copyright © 2011-2022 走看看