我无法弄清楚此查询出了什么问题。 “范围”和“存在”两者都是独立工作的,但是我一起得到parsing expection
和range malformed query, expected END_OBJECT but found FIELD_NAME
。有人可以找出这个查询有什么问题吗?
{
"query": {
"range":{
"@timestamp":{
"gte":"2019-08-04T11:00:00",
"lt":"2019-10-04T12:00:00"
}
},
"exists": {
"field": "params.zone"
}
},
"_source": ["@timestamp", "params.zone"]
}
答案 0 :(得分:1)
如果您想像合并range
和exists
一样合并多个查询,则需要使用bool query并确定哪些子句是强制性的(must
),可选(should
),过滤器(filter
)或不应在结果中显示(must_not
)
可能有效的查询如下所示(您的子句在此示例中是必需的):
{
"query": {
"bool": {
"must": [
{
"range": {
"@timestamp": {
"gte": "2019-08-04T11:00:00",
"lt": "2019-10-04T12:00:00"
}
}
},
{
"exists": {
"field": "params.zone"
}
}
]
}
},
"_source": [
"@timestamp",
"params.zone"
]
}