基于kibana的Dev Tools控制板上es常用查询语句

基于kibana的Dev Tools控制板的es常用查询语句:

1、集群相关
--- 查询集群健康状态
    GET _cluster/health

--- 查询所有节点
    GET _cat/nodes

--- 查询索引及分片的分布
    GET _cat/shards

--- 查询所有插件
    GET _cat/plugins

2、索引相关查询
--- 查询所有索引及容量
    GET _cat/indices

--- 查询索引映射结构
    GET my_index/_mapping

--- 查询所有索引映射结构    
    GET _all

--- 查询所有的相同前缀索引
    GET my-*/_search

--- 查询所有索引模板   
    GET _template

--- 查询具体索引模板
    GET _template/my_template

3.索引的操作
1、写入索引模板
PUT _template/my_template
{
    "template" : "my-*",
    "order" : 0,
    "settings" : {
        "number_of_shards" : 10,
 		"number_of_replicas" : 0
    },
    "mappings": {

      "default": {

  "_all": {
        "enabled": false
      }"properties": {
          "name": {
            "type": "text"
          },
          "age": {
            "type": "long"
          }
        }
    }
  }
}

2、创建索引映射结构
PUT my_index
{
  "mappings": {
    "doc": {
      "properties": {
        "name": {
          "type": "text"
        },
        "blob": {
          "type": "binary"
        }
      }
    }
  }
}
3、写入索引
PUT my_index/doc/1
{
  "name": "Some binary blob",
  "blob": "U29tZSBiaW5hcnkgYmxvYg==" 
}
4、删除索引
DELETE my-index
5、DSL query查询
a、查询所有
GET _search
{
  "query": {
    "match_all": {}
  }
}

b、查询单个索引 的 固定属性

--- 精确匹配

GET _search
{
  "query": {
    "term": { "name" : "you" }
  }
}

--- 模糊匹配

GET _search
{
  "query": {
    "match": { "name" : "you" }
  }
}
--- 范围查找

GET _search
{
  "query": {
    "range": {
        "age":{ "gte" : 15 , "lte" : 25 }
    }
  }
}
c、功能性查询

--- 过滤

GET my_index/_search
{
  "query": {
    "bool": {
      "filter": {
        "term":{"age":1095}
      }
    }
  }
}

--- 或  or

GET my - test / _search {
"query": {
"bool": {
"should": [{
"term": {
"name": "you"
}
}, {
"match": {
"age": 20
}
}]
}
}
}

---AND

GET my-test/_search
{
  "query": {
    "bool": {
      "must" : [{
        "match" : {
          "name" : "you"
        }
      },{
        "range":{
        "age":{
          "from" : 10 , "to" : 20
        } 
        }
      }]
    }
  }
}

---必须 =

GET my_index/_search
{
  "query": {
    "bool": {
      "must" : {
        "range" : {
          "age" : { "from" : 10, "to" : 20 }
        }
      }
    }
  }
}

--- 必须不 not

GET my_index/_search
{
  "query": {
    "bool": {
      "must_not" : {
        "term" : {
          "name" : "you"
        }
      }
    }
  }
}

d、复合查找

GET my_index/_search 
{
"query": {
"bool": {
"should": [{
"match": {
"age": 40
}
}, 
{
"match": {
"age": 20
}
}],
"filter": {
  "match":{
    "name":"you"
  }
}
}
}
}

e、索引迁移

--- 场景 从A索引 复制到B索引
POST _reindex
{
  "source": {
    "index": "my_index"
  },
  "dest": {
    "index": "new_my_index"
  }
}



f、基于查询的删除

POST test-index/_delete_by_query
{
  "query":{
        "term": {
         "cameraId":"00000000002"
        }
  }

}

--- 查询

GET test-index/_search
{
  "query":{
        "term": {
         "cameraId":"00000000002"
        }
  }
}
  • 2
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值