收到 query_string 格式错误的查询,预计 [END_OBJECT] 但发现 [FIELD_NAME]
getting query_string malformed query, expected [END_OBJECT] but found [FIELD_NAME]
我在尝试执行时遇到以下查询,但出现异常 [query_string] 格式错误的查询,预计 [END_OBJECT] 但发现 [FIELD_NAME]
{
"query" : {
"query_string": {
"default_field": "shipmentId",
"query": "\"123\""
},
"bool" : {
"filter" : {
"terms" : {
"exceptionId" : ["1", "2"]
}
},
"must_not" : {
"terms" : {
"id" : ["1"]
}
}
}
}
}
您的查询几乎是正确的,您只需将 query_string
查询移动到 bool/must
部分:
{
"query": {
"bool": {
"must": {
"query_string": {
"default_field": "shipmentId",
"query": "\"123\""
}
},
"filter": {
"terms": {
"exceptionId": [
"1",
"2"
]
}
},
"must_not": {
"terms": {
"id": [
"1"
]
}
}
}
}
}
我在尝试执行时遇到以下查询,但出现异常 [query_string] 格式错误的查询,预计 [END_OBJECT] 但发现 [FIELD_NAME]
{
"query" : {
"query_string": {
"default_field": "shipmentId",
"query": "\"123\""
},
"bool" : {
"filter" : {
"terms" : {
"exceptionId" : ["1", "2"]
}
},
"must_not" : {
"terms" : {
"id" : ["1"]
}
}
}
}
}
您的查询几乎是正确的,您只需将 query_string
查询移动到 bool/must
部分:
{
"query": {
"bool": {
"must": {
"query_string": {
"default_field": "shipmentId",
"query": "\"123\""
}
},
"filter": {
"terms": {
"exceptionId": [
"1",
"2"
]
}
},
"must_not": {
"terms": {
"id": [
"1"
]
}
}
}
}
}