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

  • 相关阅读:
    nginx获取上游真实IP(ngx_http_realip_module)
    配置NFS固定端口
    elasticsearch 占CPU过高
    jdk集合常用方法分析之HashSet和TreeSet
    SparkSQL使用之如何使用UDF
    SparkSQL使用之JDBC代码访问Thrift JDBC Server
    SparkSQL使用之Thrift JDBC server
    SparkSQL使用之Spark SQL CLI
    jdk分析之String
    jdk集合常用方法分析之ArrayList&LinkedList&以及两者的对比分析
  • 原文地址:https://www.cnblogs.com/zhangyi0331/p/9357058.html
Copyright © 2011-2022 走看看