Elasticsearch-query_string查询

官方文档

地址(https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#query-string-syntax)

任何时候还是官方文档看着最有用啊

Es结构

这是一条查询结果示例:

#! Deprecation: [types removal] Specifying types in search requests is deprecated.
{
  "took" : 911,
  "timed_out" : false,
  "_shards" : {
    "total" : 16,
    "successful" : 16,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 516,
      "relation" : "eq"
    },
    "max_score" : null,
    "hits" : [
      {
        "_index" : "log-2022.04",
        "_type" : "_doc",
        "_id" : "",
        "_score" : null,
        "_source" : {
          "time" : "2022-04-29T08:36:05.034Z",
          "param" : "",
          "status" : 200,
          "@version" : "1",
          "agent" : {
            "id" : "",
            "name" : "app",
          },
          "level" : "info",
          "appid" : "",
          "tags" : [
            "aa"
          ],
          "fields" : {
            "source" : "aa"
          },
       
        },
        "sort" : [
          1651221365034
        ]
      }
    ]
  }
}

各输出字段介绍

嵌套属性查询

只匹配嵌套属性中的一个属性

由前述可知:属性agent里仍有两个属性,现在要指定匹配agent.id,
使用以下格式:
agent.\id:(内容)



GET /prod_feifan_fwlog*/_doc/_search
{
    "query":{
        "query_string":{
            "query":"(time:[2022-03-31T00:00:00Z TO 2022-04-29T15:59:59Z]) AND  (agent.\\id:(\"2f0894c2-2fc4-4asndvksndk5cddf\")) AND ( adress:(\"login\" OR \"logout\"))"
        }
    },
    "from":0,
    "size":20,
    "sort":[
        {
            "time":"desc"
        }
    ],
    "highlight":{

    }
}

匹配嵌套属性中的任意一个属性

agent.\*:(内容)


以下是官方文档:
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值