如何在opensearch中过滤多个字段以及geo_distance



目前我有一个弹性搜索查询,它仅基于地理距离的km半径过滤。我想搜索多个字段以及地理距离过滤器。

这是我的查询:

{
"query": {
"bool": {
"filter": {
"geo_distance": {
"distance": "5km",
"coordinate": {
"lat": 3.131779652034938,
"lon": 101.6846340901202
}
}
}
}
}
}

下面是我从elastic -search得到的响应:

{
"took": 17,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 11,
"relation": "eq"
},
"max_score": 0.0,
"hits": [
{
"_index": "drivers",
"_id": "Oj07uYEBZP3C5zS1xL7e",
"_score": 0.0,
"_source": {
"id": 1,
"name": "Dwayne Johnson",
"area": "Brick Fields",
"coordinate": {
"lat": 3.130143699375071,
"lon": 101.68389642814743
},
"vehicles": [
{
"vehicle_type": "Car",
"weight_capacity": "500",
"vehicle_number": "WM3219"
},
{
"vehicle_type": "Large Truck",
"weight_capacity": "1000",
"vehicle_number": "VAV3234"
}
],
"deposit": "1500"
}
}]
}
}

我想过滤存款值从驱动程序对象以及地理距离使用弹性搜索查询。有谁能帮我解答这个问题吗?

如果你想要一个额外的过滤器正如我从问题

中理解的那样
{
"query":{
"bool":{
"must":[
{
"term":{
"deposit":"<some value>"
}
}
],
"filter":{
"geo_distance":{
"distance":"5km",
"coordinate":{
"lat":3.131779652034938,
"lon":101.6846340901202
}
}
}
}
}
}

最新更新