------------mysql------------------------------------
SELECT st_distance(POINT(118.816334, 32.023290),POINT(118.7888900000, 32.01772))*111195 AS distant;
=3113.853200404186
SELECT st_distance_sphere(POINT(118.816334, 32.023290),POINT(118.7888900000, 32.01772)) AS distant;
=2660.4448185827
----在線---------------
POINT(118.816334, 32.023290),POINT(118.7888900000, 32.01772) = 2658.78
-----es-----------------(跟mysql-st_distance_sphere差不多)
POINT(118.816334, 32.023290),POINT(118.7888900000, 32.01772) = 2660.4561920887677
store/_search
{
"query": {
"bool": {
"must": {
"match_all": {}
},
"filter": {
"geo_distance": {
"distance": "1km",
"theGeom": {
"lat": 32.023290,
"lon": 118.816334
}
}
}
}
},
"sort": [
{
"_geo_distance": {
"theGeom": {
"lat": 32.023290,
"lon": 118.816334
},
"order": "asc"
}
}
]
}