弹性搜索查询结果'No query registered for [must]'



ES 版本 2.3,我正在尝试使用 filter & query 在 elasticsearch 服务器上运行搜索。我有几个键想搜索,有些必须是结果的一部分,">主机"键应该在结果中(因为我想要来自多个主机的结果,而不仅仅是一个(

这是我尝试运行的查询,由于某种原因,我收到一个错误,说 - "search_phase_execution_exception - 没有为 [must]注册查询">

{
"query": {
"filtered": {
"filter": {
"bool": {
"must": [{
"range": {
"@timestamp": {
"gte": 1503751766908,
"lte": 1503751786908,
"format": "epoch_millis"
}
},
"query": {
"should": [{
"match_phrase": {
"host": "host1"
}
}, 
{"match_phrase": {
"host": "host2"
}
}],
"must": [{
"match_phrase": {
"key1": "value1"
}
}]
}
}]
}
}
}
}
}

你已经把它弄混了一点,试试这个:

{
"query": {
"bool": {
"must": [
{
"match_phrase": {
"key1": "value1"
}
},
{
"range": {
"@timestamp": {
"gte": 1503751766908,
"lte": 1503751786908,
"format": "epoch_millis"
}
}
}
],
"minimum_should_match": 1,
"should": [
{
"match": {
"host": "host1"
}
},
{
"match": {
"host": "host2"
}
}
]
}
}
}

相关内容

最新更新