我正在使用弹性搜索头运行以下POST查询,由于某种原因,我在响应窗口中收到如下错误:
请求:-
{
"query": {
"bool": {
"must": [
{
"match": {
"state": "jakarta"
}
},
{
"match": {
"country_name": "indonesia"
}
}
],
"filter": [
{
"match": {
"status": true
}
},
{
}
]
}
},
"sort": [
{
"master_sort": {
"order": "desc"
}
}
]
}
错误:-
{
"error": {
"root_cause": [
{
"type": "illegal_argument_exception",
"reason": "query malformed, empty clause found at [1:495]"
}
],
"type": "illegal_argument_exception",
"reason": "query malformed, empty clause found at [1:495]"
},
"status": 400
}
请建议如何处理此类错误。目前,我正在使用6.8版本的elastic-search。我正在Rails应用程序中实现它。
答案 0 :(得分:0)
错误消息表明您的查询中有一个空子句,首先要删除该子句,它位于您的过滤器上下文中:
"query": {
"bool": {
"must": [
{
"match": {
"state": "jakarta"
}
},
{
"match": {
"country_name": "indonesia"
}
}
],
"filter": [
{
"match": {
"status": true
}
},
{<=======//to remove
}<=======//to remove
]
}
},
"sort": [
{
"master_sort": {
"order": "desc"
}
}
]
}