假设我要搜索距离三个地理位置A,B或C任意5公里以内的文档。是否可以在单个查询中执行该操作或如何执行?
最佳答案
是的,您可以将bool/should
查询与三个geo_distance
查询一起使用。
POST /your_index/_yearch
{
"query": {
"bool": {
"should": [
{
"geo_distance": {
"distance": "5km",
"pin.location": {
"lat": 40,
"lon": -70
}
}
},
{
"geo_distance": {
"distance": "5km",
"pin.location": {
"lat": 41,
"lon": -71
}
}
},
{
"geo_distance": {
"distance": "5km",
"pin.location": {
"lat": 42,
"lon": -72
}
}
}
]
}
}
}
关于elasticsearch - 如何在多个地理点上使用Elasticsearch距离查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36898936/