kibana中Console的ES查询----持续更新

这篇博客详细介绍了Elasticsearch中不同类型的查询方式,包括基本的全量查询、分页查询、按ID排序查询以及更复杂的布尔组合查询。同时,通过官方指导展示了如何进行多条件的符合查询和嵌套条件查询,帮助读者深入理解Elasticsearch的查询语法和技巧。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

目录

查询

合并查询

官方指导

查询

这种查询表达式,查询索引kvedr-account-statistics为例

GET kvedr-account-statistics/_search
{"query": { "match_all": {} }}
GET kvedr-hostevents-2022.05.11/_search
{
	"query": {
		"match_all": {}
	},
	"from": 1,
	"size": 3,
	"sort": {
		"_id": {
			"order": "desc"
		}
	}
}

GET kvedr-hostevents-2022.05.11/_search
{
	"query": {
		"match": {
			"doc.event.hdr.puid": "00627b1e71004b8c"
		}
	},
	"from": 0,
	"size": 10,
	"sort": {
		"@timestamp": {
			"order": "desc"
		}
	}
}

合并查询

多个and条件查询就需要用到bool。

GET kvedr-hostevents-2022.05.12/_search
{
  "from": 0,
  "size": 10,
  "sort": [
    {
      "@timestamp": {
        "order": "desc"
      }
    }
  ], 
  "query": {
    "bool": {
      "must": [
        {"term": {"doc.event.hdr.type": {"value": 7}}},
        {"term": {"doc.event.log.type": {"value": "postfix"}}}
      ]
    }
  }
}

官方指导

符合查询

{
    "bool": {
        "must":     { "match": { "tweet": "elasticsearch" }},
        "must_not": { "match": { "name":  "mary" }},
        "should":   { "match": { "tweet": "full text" }},
        "filter":   { "range": { "age" : { "gt" : 30 }} }
    }
}

复合条件嵌套查询

{
    "bool": {
        "must": { "match":   { "email": "business opportunity" }},
        "should": [
            { "match":       { "starred": true }},
            { "bool": {
                "must":      { "match": { "folder": "inbox" }},
                "must_not":  { "match": { "spam": true }}
            }}
        ],
        "minimum_should_match": 1
    }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值