我的 Elasticsearch 查询有什么问题?
What is wrong with my Elastisearch query?
我需要同时进行 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,我想我的查询可能有错误的语法?
我更改了语法并且此查询有效:
{
"query": {
"bool": {
"must": {
"multi_match": {
"query": "kotlety*",
"fields": [
"name"
]
}
},
"filter": {
"term": {
"status": 2
}
}
}
}
}
查询不能同时包含布尔值和 multi_match。你可以这样重新排列它:
{
"query": {
"bool": {
"filter": {
"term": {
"status": 2
}
},
"should": {
"multi_match": {
"query": "kotlety*",
"fields": [
"name"
]
}
}
}
},
"size": 24
}
我需要同时进行 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,我想我的查询可能有错误的语法?
我更改了语法并且此查询有效:
{
"query": {
"bool": {
"must": {
"multi_match": {
"query": "kotlety*",
"fields": [
"name"
]
}
},
"filter": {
"term": {
"status": 2
}
}
}
}
}
查询不能同时包含布尔值和 multi_match。你可以这样重新排列它:
{
"query": {
"bool": {
"filter": {
"term": {
"status": 2
}
},
"should": {
"multi_match": {
"query": "kotlety*",
"fields": [
"name"
]
}
}
}
},
"size": 24
}