elasticsearch - 如何在弹性搜索中基于多个地理点搜索文档?
问题描述
我有一个用例,我想在其中搜索具有多个地理点的文档。
{
"query": {
"bool": {
"must": {
"match_all": {}
},
"filter": {
"geo_distance": {
"distance": "100m",
"nc_extraData.nc_geoPoint": {
"lat": 21.36042723377568,
"lon": -5.646749208228298
}
}
}
}
}
}
此查询仅支持单个地理点。可能吗。
解决方案
您可以添加多个geo_distance
具有不同地理点的约束。您还可以使用命名查询知道哪个点匹配:
{
"query": {
"bool": {
"should": [
{
"geo_distance": {
"distance": "100m",
"nc_extraData.nc_geoPoint": {
"lat": 21.36042723377568,
"lon": -5.646749208228298
},
"_name": "point 1"
}
},
{
"geo_distance": {
"distance": "100m",
"nc_extraData.nc_geoPoint": {
"lat": 22.36042723377568,
"lon": -6.646749208228298
},
"_name": "point 2"
}
},
{
"geo_distance": {
"distance": "100m",
"nc_extraData.nc_geoPoint": {
"lat": 23.36042723377568,
"lon": -7.646749208228298
},
"_name": "point 3"
}
}
]
}
}
}
推荐阅读
- flutter - Flutter为Json源添加前缀
- r - R代码:列到行,即组到个人
- c# - ModelState.IsValid 对于发送带有隐藏输入的 Id 为 false
- javascript - 自定义排序,未显示更新数据的组件做出反应
- python - 当我想检查 Dataframe 是否为空时,“list”对象没有属性“isEmpty”
- sql - 与系统表的内部联接
- sql - 无法识别的姓名:[9:8] 的员工
- winapi - 如何从 windcodecs api IWICBitmapDecoder、IWICBitmap 或 IWICImagingFactory 获取 GDI 兼容位图?
- python - 尝试在概念表中显示带有 yfinance 和 notion-py 的股息
- assembly - 指令解码器如何区分前缀和主操作码?