阅读 69

项目问题排查中的ES常用命令

查看/索引名称/的数据结构

curl ip:9200/indices/_mapping?pretty

查看所有索引

curl ip:9200/_cat/indices?v

删除索引

  • 删除指定索引
    curl -XDELETE ip:9200/system-log-2019.05
    其中system-log-2019.05为索引全称

  • 删除多个索引
    curl -XDELETE ip:9200/system-log-2019.05,system-log-2019.05

  • 删除所有索引
    curl -XDELETE ip:9200/_all
    或者
    curl -XDELETE ip:9200/*

新增索引

curl -XPUT <http://ip:9200/test-index

模板

curl -XDELETE localhost:9200/_template/template_1

curl -XGET localhost:9200/_template/template_1

修复索引字段上限

curl -XPUT [http://ip:9200/出问题的那个索引名称/_settings](http://ip:9200/%E5%87%BA%E9%97%AE%E9%A2%98%E7%9A%84%E9%82%A3%E4%B8%AA%E7%B4%A2%E5%BC%95%E5%90%8D%E7%A7%B0/_settings) -d '{"index.mapping.total_fields.limit": 2000}' 复制代码

更新模板(!!覆盖式更新)

curl -XPUT <http://ip:9200/_template/ctu->* -d '{"template":"ctu-*","settings":{"index.mapping.total_fields.limit":2000}}' 复制代码

ES动态模板类型推断### 查看/索引名称/的数据结构

curl 10.1.2.48:9200/indices/_mapping?pretty curl 10.2.1.106:9200/case-manager-center/_mapping?pretty curl 10.1.2.48:9200/_cat/indices?v 复制代码

删除索引

  • 删除指定索引
    curl -XDELETE 192.168.1.4:9200/system-log-2019.05
    其中system-log-2019.05为索引全称

  • 删除多个索引
    curl -XDELETE 192.168.1.4:9200/system-log-2019.05,system-log-2019.05

  • 删除所有索引
    curl -XDELETE 192.168.1.4:9200/_all
    或者
    curl -XDELETE 192.168.1.4:9200/*

新增索引

curl -XPUT http://10.1.2.48:9200/case-manager-center

模板

curl -XDELETE localhost:9200/_template/template_1

curl -XGET localhost:9200/_template/template_1

修复索引字段上限

curl -XPUT http://ip:9200/出问题的那个索引名称/_settings -d '{"index.mapping.total_fields.limit": 2000}'

更新模板(!!覆盖式更新)

curl -XPUT http://ip:9200/_template/ctu-* -d '{"template":"ctu-*","settings":{"index.mapping.total_fields.limit":2000}}'

聚合查询

{ "from": 0, "size": 10000, "query": { "bool": { "must": [ { "range": { "requestTime": { "from": "2021-01-22 00:00:00", "to": "2021-01-22 23:59:59", "include_lower": true, "include_upper": true, "time_zone": "+08:00", "format": "yyyy-MM-dd HH:mm:ss", "boost": 1.0 } } }, { "terms": { "appId": [ "1" ], "boost": 1.0 } } ], "disable_coord": false, "adjust_pure_negative": true, "boost": 1.0 } }, "sort": [ { "requestTime": { "order": "desc" } } ], "aggregations": { "riskRuleIds": { "terms": { "field": "reviewRuleIds", "size": 10, "min_doc_count": 1, "shard_min_doc_count": 0, "show_term_doc_count_error": false, "order": [ { "_count": "desc" }, { "_term": "asc" } ] } } } }


作者:ShowMaker
链接:https://juejin.cn/post/7022812428383715365


文章分类
后端
版权声明:本站是系统测试站点,无实际运营。本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 XXXXXXo@163.com 举报,一经查实,本站将立刻删除。
相关推荐