官方文档
地址(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.\*:(内容)
以下是官方文档: