我需要同时进行multi_match和bool查询,但下面的查询不起作用:(当我单独使用它们时,它们工作得很好。
{
"query": {
"multi_match": {
"query": "kotlety*",
"fields": [
"name"
]
},
"bool": {
"filter": {
"term": {
"status": 2
}
}
}
},
"size": 24
}
响应为:
{
"error": {
"root_cause": [
{
"type": "parsing_exception",
"reason": "[multi_match] malformed query, expected [END_OBJECT] but found [FIELD_NAME]",
"line": 9,
"col": 5
}
],
"type": "parsing_exception",
"reason": "[multi_match] malformed query, expected [END_OBJECT] but found [FIELD_NAME]",
"line": 9,
"col": 5
},
"status": 400
}
Elastic 6.6,我想我的查询可能有错误的语法?
发布于 2019-03-25 11:08:25
查询不能同时包含布尔值和multi_match。你可以像这样重新安排它:
{
"query": {
"bool": {
"filter": {
"term": {
"status": 2
}
},
"should": {
"multi_match": {
"query": "kotlety*",
"fields": [
"name"
]
}
}
}
},
"size": 24
}
发布于 2019-03-25 11:07:31
我更改了语法,此查询可以工作:
{
"query": {
"bool": {
"must": {
"multi_match": {
"query": "kotlety*",
"fields": [
"name"
]
}
},
"filter": {
"term": {
"status": 2
}
}
}
}
}
https://stackoverflow.com/questions/55336153
复制相似问题