Skip to content

Latest commit

 

History

History
117 lines (80 loc) · 1.33 KB

ES常用操作.md

File metadata and controls

117 lines (80 loc) · 1.33 KB

ES 常用操作

搜索全部:

GET _search
{
  "query": {
    "match_all": {}
  }
}

查看节点并按名称排序:

GET /_cat/nodes?s=name&v

查看磁盘使用量:

GET /_cat/allocation?v

创建索引:

PUT /test?pretty

查看索引的设置:

GET /test/_setting?pretty

创建索引时设置分片和副本:

PUT /test-1/?pretty
{
  "setting": {
     "number_of_shards": 15,
     "number_of_replicas": 5
  }
}

查看分片分布:

GET /_cat/shards/test-1?s=shard&v

查看文档数量:

GET /_cat/count?v

某一索引的文档数量:

GET /_cat/count/sessions2-200803?v

查看索引列表,按大小排序:

GET /_cat/indices?s=store.size:desc&v

为将来的索引设置默认分片和副本 :

PUT /_template/log
{
  "index_patterns": "session2-*",
  "settings": {
    "number_of_shards": 6,
    "number_of_replicas": 1
  }
}

分片数量是不能修改的,但是可以修改副本数量:

PUT /sessions2-200804/_settings
{
  "index" : {
    "number_of_replicas" : 0
  }
}

开启慢查询日志

PUT /_all/_settings?preserve_existing=true
{
  "index.search.slowlog.threshold.fetch.warn": "4s",
  "index.search.slowlog.threshold.query.warn": "4s"
}