Elasticsearch CURL操作方法

Elasticsearch curl操作


  1. _cat操作

    curl localhost:9200/_cat
    =^.^=
    /_cat/allocation
    /_cat/shards
    /_cat/shards/{index}
    /_cat/master
    /_cat/nodes
    //獲得集羣的所有節點
    /_cat/indices
    //獲得集羣所有的index
    /_cat/indices/{index}
    /_cat/segments
    /_cat/segments/{index}
    /_cat/count
    /_cat/count/{index}
    /_cat/recovery
    /_cat/recovery/{index}
    /_cat/health
    //獲得集羣健康情況
    /_cat/pending_tasks
    /_cat/aliases
    /_cat/aliases/{alias}
    /_cat/thread_pool
    /_cat/plugins
    /_cat/fielddata
    /_cat/fielddata/{fields}
  2. 索引操作

    1、獲取索引
    curl -XGET ‘http://localhost:9200/{index}/{type}/{id}
    2、索引數據(插入數據)
    curl -XPOST ‘http://localhost:9200/{index}/{type}/{id}’ -d'{“a”:”avalue”,”b”:”bvalue”}
    3、刪除索引
    curl -XDELETE ‘http://localhost:9200/{index}/{type}/{id}
  3. 刪除數據

    • 簡單刪除(根據id)

      curl -XDELETE 'http://localhost:9200/{index}/{type}/{id}?timeout=5m'
    • 按照查詢條件刪除數據

      curl -XPOST 'localhost:9200/{index}/{type}/_delete_by_query?pretty' -d'
      {
        "query": { 
          "query_string": {
            "message": "some message"
          }
        }
      }'
發佈了45 篇原創文章 · 獲贊 35 · 訪問量 34萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章