我正在尝试使用geo_point基于OR条件查找结果并按距离排序。我在这里发布了我为OR条件尝试过的代码。这显示错误没有为[should]
注册的查询{
"query": {
"filtered": {
"filter": {
"geo_distance": {
"distance": "5000km",
"location": {
"lat": 28.613939,
"lon": 77.209021
}
},
"bool": {
"should": [
{
"term": {
"maincat_id": "55b2326501fcff8a338b4569"
}
}
]
}
}
}}}
但它显示我错误[geo_distance]查询不支持[bool] 请帮我解决一下
答案 0 :(得分:1)
这个怎么样?
{
"query": {
"filtered": {
"filter": {
"bool": {
"must": [
{
"geo_distance": {
"distance": "5000km",
"location": {
"lat": 28.613939,
"lon": 77.209021
}
}
}
],
"should": [
{
"term": {
"maincat_id": "55b2326501fcff8a338b4569"
}
},
{
"term": {
"maincat_id": "55b2326501fcff8a338b4578"
}
},
{
"term": {
"maincat_id": "567a47e801fcff55228b4567"
}
}
]
}
}
}
}
}