ElasticSearch:比较文档中的两个地理点
ElasticSearch: compare two geopoints in document
考虑到以下文档,我只想查询当前位置在目标位置 1 英里范围内的文档。
{
current_location: {
lat: 34.0583,
lon: -118.2476
},
destination_location: {
lat: 33.989521,
lon: -117.531614
}
}
使用地理距离过滤器:
{
"query": {
"filtered": {
"filter": {
"geo_distance": {
"distance": "1.6km",
"destination_location": "34.05,-118.24"
}
}
}
}
}
34.05 是纬度,(-118.24) 是经度。
1 英里 = 1.6 公里
考虑到以下文档,我只想查询当前位置在目标位置 1 英里范围内的文档。
{
current_location: {
lat: 34.0583,
lon: -118.2476
},
destination_location: {
lat: 33.989521,
lon: -117.531614
}
}
使用地理距离过滤器:
{
"query": {
"filtered": {
"filter": {
"geo_distance": {
"distance": "1.6km",
"destination_location": "34.05,-118.24"
}
}
}
}
}
34.05 是纬度,(-118.24) 是经度。
1 英里 = 1.6 公里