• ES 常用语句增删改查


    • 快速查看ES集群状态
    GET _cluster/health
    
    {
      "cluster_name": "elasticsearch",
      "status": "yellow",
      "timed_out": false,
      "number_of_nodes": 1,
      "number_of_data_nodes": 1,
      "active_primary_shards": 16,
      "active_shards": 16,
      "relocating_shards": 0,
      "initializing_shards": 0,
      "unassigned_shards": 16,
      "delayed_unassigned_shards": 0,
      "number_of_pending_tasks": 0,
      "number_of_in_flight_fetch": 0,
      "task_max_waiting_in_queue_millis": 0,
      "active_shards_percent_as_number": 50
    }
    
    • 快速查看ES集群的索引信息
    GET _cat/indices?v
    
    health status index      uuid                   pri rep docs.count docs.deleted store.size pri.store.size
    yellow open   test_type  ZTEhg0JqQiC3rn_afvle5Q   5   1          1            0      4.1kb          4.1kb
    yellow open   test_index C-03qY6HRWCuCVPvNgRD2w   5   1          2            0      7.2kb          7.2kb
    yellow open   ecommerce  84jwaWkVSDKtBHVfGOn8TQ   5   1          2            0     10.2kb         10.2kb
    yellow open   .kibana    XsGtygBSQb-MNkbAPCbI9Q   1   1          1            0      3.1kb          3.1kb
    
    • 创建索引
    PUT /test_index
    
    创建完成后,再执行 GET _cat/indices?v 就能看到创建的 /test_index 索引了
    
    • 删除索引
    DELETE /test_index
    
    删除完成后,再执行 GET _cat/indices?v 就看不到已经删除的 /test_index 索引了
    
    • 创建文档
    PUT /index/type/id
    {
    	json数据
    }
    
    PUT /ecommerce/product/100
    {
        "name":"yunnanbaiyao",
        "desc":"laji",
        "price":40,
        "producer":"yunnanyaoshi",
        "tags":["haha","heihei"]
    }
    
    • 替换文档,必须带上所有field,要不然没有带的field更新后就没有值了
    PUT /index/type/id
    {
    	json数据
    }
    
    PUT /ecommerce/product/100
    {
        "name":"plus yunnanbaiyao",
        "desc":"laji",
        "price":40,
        "producer":"yunnanyaoshi",
        "tags":["haha","heihei"]
    }
    
    • 更新文档
    POST /index/type/id/_update
    {
    	"doc":{json数据}
    }
    
    POST /ecommerce/product/100/_update
    {
      "doc": {"name":"hahahhaha"}
    }
    
    • 查询文档
    GET /index/type/id
    
    GET /ecommerce/product/100
    
    执行该命令,就能看到我们刚才通过PUT创建的文档了
    
    • 删除文档
    DELETE /index/type/id
    
    DELETE /ecommerce/product/100
    
  • 相关阅读:
    fiddler https
    Windows Media Player 网页播放器 参数含义
    ActionScript3.0程序开发工具
    同一目录两程序引用同一个类库dll,所引发的问题
    Flash在浏览器里调试获取trace
    linux下的i2c驱动框架
    IIC原理及简单流程
    Linux操作系统下 NAND FLASH驱动程序框架
    Linux操作系统简单NOR FLASH驱动开发
    网卡驱动
  • 原文地址:https://www.cnblogs.com/rocker-pg/p/14673031.html
Copyright © 2020-2023  润新知