elasticsearch常用命令

最近接触到elasticsearch,需要使用命令进行多种操作,由于对es不是很熟悉,记录一下常用的curl和kinaba命令。

1.查询es信息

curl

curl -XGET "http://192.168.10.101:9200/" -H "kbn-xsrf: reporting"

kibana

GET /

2.查询所有索引信息

curl

curl -XGET "http://192.168.10.101:9200/_cat/indices?v" -H "kbn-xsrf: reporting"

kibana

GET /_cat/indices?v

3.查询节点状态

curl

curl -XGET "http://192.168.10.101:9200/_cat/nodes?v" -H "kbn-xsrf: reporting"

kibana

GET /_cat/nodes?v

4.查询索引结构信息

curl

curl -XGET "http://192.168.10.101:9200/proof_data?pretty=true" -H "kbn-xsrf: reporting"

kibana

GET /proof_data?pretty=true

5.创建索引

curl

curl -XPUT "http://192.168.10.101:9200/new_index_data/" -H "kbn-xsrf: reporting" -H "Content-Type: application/json" -d'
{
    "aliases" : { },
    "mappings" : {
      "properties" : {
        "BIZ_ID" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "BIZ_TYPE_ID" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "CHANNEL" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "CREATE_TIME" : {
          "type" : "date"
        },
        "ORGANIZE_CODE" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "TRANSACTION_ID" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "USER_ID" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "USE_ENCRYPT" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "id" : {
          "type" : "long"
        },
        "virtual_channel_id" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        }
      }
    }
}'

kibana

PUT /new_index_data/
{

    "aliases" : { },

    "mappings" : {

      "properties" : {

        "BIZ_ID" : {

          "type" : "text",

          "fields" : {

            "keyword" : {

              "type" : "keyword",

              "ignore_above" : 256

            }

          }

        },

        "BIZ_TYPE_ID" : {

          "type" : "text",

          "fields" : {

            "keyword" : {

              "type" : "keyword",

              "ignore_above" : 256

            }

          }

        },

        "CHANNEL" : {

          "type" : "text",

          "fields" : {

            "keyword" : {

              "type" : "keyword",

              "ignore_above" : 256

            }

          }

        },

        "CREATE_TIME" : {

          "type" : "date"

        },

        "ORGANIZE_CODE" : {

          "type" : "text",

          "fields" : {

            "keyword" : {

              "type" : "keyword",

              "ignore_above" : 256

            }

          }

        },

        "TRANSACTION_ID" : {

          "type" : "text",

          "fields" : {

            "keyword" : {

              "type" : "keyword",

              "ignore_above" : 256

            }

          }

        },

        "USER_ID" : {

          "type" : "text",

          "fields" : {

            "keyword" : {

              "type" : "keyword",

              "ignore_above" : 256

            }

          }

        },

        "USE_ENCRYPT" : {

          "type" : "text",

          "fields" : {

            "keyword" : {

              "type" : "keyword",

              "ignore_above" : 256

            }

          }

        },

        "id" : {

          "type" : "long"

        },

        "virtual_channel_id" : {

          "type" : "text",

          "fields" : {

            "keyword" : {

              "type" : "keyword",

              "ignore_above" : 256

            }

          }

        }

      }

    }

}

6.查询索引的Settings配置

curl

curl -XGET "http://192.168.10.101:9200/new_index_data/_settings" -H "kbn-xsrf: reporting"

kibana

GET /new_index_data/_settings

7.查询索引下所有数据

curl

# 带条件查询
curl -XGET "http://192.168.10.101:9200/proof_data/_search" -H "kbn-xsrf: reporting" -H "Content-Type: application/json" -d'
{
  "query": {
    "match_all": {}
  }
}'

# 不带条件查询
curl -XGET "http://192.168.10.101:9200/proof_data/_search" -H "kbn-xsrf: reporting"

kibana

GET /proof_data/_search
{

  "query": {

    "match_all": {}

  }

}

8.查询索引下数据总量

curl

curl -XGET "http://192.168.10.101:9200/proof_data/_count" -H "kbn-xsrf: reporting"

kibana

GET /proof_data/_count

9.删除索引

curl

curl -XDELETE "http://192.168.10.101:9200/new_index_data/" -H "kbn-xsrf: reporting"

kibana

DELETE /new_index_data/

10.删除索引下的数据

curl

curl -XPOST "http://192.168.10.101:9200/index_name/_delete_by_query" -H "kbn-xsrf: reporting" -H "Content-Type: application/json" -d'
{
  "query":{
    "match_all":{}
  }
}'

此语句可以根据query条件,进行选择性删除数据。

kibana

POST /index_name/_delete_by_query
{
  "query":{
    "match_all":{}
  }
}

11.查询es健康状况

curl

curl -XGET "http://192.168.10.101:9200/_cat/health?v" -H "kbn-xsrf: reporting"

kibana

GET /_cat/health?v

相关推荐

  1. elasticsearch命令

    2024-02-19 12:18:03       29 阅读
  2. ElasticSearch 运维命令收集

    2024-02-19 12:18:03       27 阅读
  3. Elasticsearch语句

    2024-02-19 12:18:03       17 阅读
  4. Elasticsearch 优化思路

    2024-02-19 12:18:03       36 阅读
  5. Kubernetes 命令

    2024-02-19 12:18:03       35 阅读
  6. Pgsql命令

    2024-02-19 12:18:03       32 阅读
  7. git命令

    2024-02-19 12:18:03       44 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-02-19 12:18:03       17 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-02-19 12:18:03       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-02-19 12:18:03       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-02-19 12:18:03       18 阅读

热门阅读

  1. 【国产MCU】-CH32V307-通用定时器(GPTM)-PWM输出

    2024-02-19 12:18:03       37 阅读
  2. 消息中间件-RocketMQ

    2024-02-19 12:18:03       25 阅读
  3. CCF编程能力等级认证GESP—C++5级—20231209

    2024-02-19 12:18:03       24 阅读
  4. SQL实现模糊查询的四种方法总结

    2024-02-19 12:18:03       27 阅读
  5. 【C++】const与constexpr详解

    2024-02-19 12:18:03       23 阅读
  6. Python函数(二)

    2024-02-19 12:18:03       27 阅读
  7. 一句话木马

    2024-02-19 12:18:03       26 阅读
  8. 待处理的研究内容

    2024-02-19 12:18:03       31 阅读
  9. 汽车零部件软件开发中常用滤波算法

    2024-02-19 12:18:03       22 阅读
  10. c# B+树

    2024-02-19 12:18:03       28 阅读