Home > other >  Elasticsearch search content according to the scheduling problem with distance
Elasticsearch search content according to the scheduling problem with distance

Time:11-04

Recently found out that my code a bug
With es will be ordered by the search content according to the distance I recently found that the results into a
This kind of order 32159,66,42,255


Finally through careful screening found that the distance of the above is my compute, and es own calculated distance is
24,51,77,163,190 this order is right

On the map by examination revealed my own distance was calculated by the latitude and longitude algorithm is sure

But why would es calculation of distance and I send so much?
I even had a distance calculation is more than 1500, and es calculation is more than 3000

For example,
106.530495, 29.60383 to 106.526634, 29.600001

My calculation is 447 m
Es calculation is 566 m

Don't give me that coordinate system problems, I use the seven or eight coordinate system to calculate, is 446 m or 447 m, I can accept the error of a few meters, but this kind of error of more than 20%, even 50% error cannot tolerate

O ES a great god help see

GET/busi/info/_search
{
"Query" : {
"Term" : {
"AddrProvince" : {
"Value", "Shanghai"
}
}
},
"Sort" : [
{
"_geo_distance" : {
"Position" : [106.530495, 29.60383],
"Order" : "asc",
"Unit", "m"
}
}
]
}



{
"_index" : "busimerc,"
"_type", "info",
"_id" : "2011031530045414561",
"_score" : null,
"_source" : {
"Id" : "222",
"AddrProvince", "Shanghai",
"Name" : "test information,"
"Position" : {
"Lat" : 29.600001,
"Lon" : 106.526634
}
},
"Sort" : [
566.2403312493584
]
}
  • Related