-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
Labels
bugmilliRelated to the milli workspaceRelated to the milli workspacev0.26.0PRs/issues solved in v0.26.0PRs/issues solved in v0.26.0
Milestone
Description
Describe the bug
The result is not sorted by distance to the given lat/lng when using _geoPoint sorting function
To Reproduce
Use the following data
[
{
"id":"1",
"_geo":{
"lat":48.2187834,
"lng":16.392127
}
},
{
"id":"2",
"_geo":{
"lat":48.26579,
"lng":16.4281601
}
},
{
"id":"3",
"_geo":{
"lat":48.19431,
"lng":16.4071101
}
},
{
"id":"4",
"_geo":{
"lat":48.22919,
"lng":16.3679401
}
}
]
When using the _geoPoint sort function
curl -X POST 'http://localhost:7700/indexes/test/search' -H 'Content-type:application/json' --data-binary '{ "sort": ["_geoPoint(48.2342154, 16.4205687):asc"] }'
You get the following result:
{
"hits":[
{
"id":"1",
"_geo":{
"lat":48.2187834,
"lng":16.392127
},
"_geoDistance":2717
},
{
"id":"2",
"_geo":{
"lat":48.26579,
"lng":16.4281601
},
"_geoDistance":3556
},
{
"id":"3",
"_geo":{
"lat":48.19431,
"lng":16.4071101
},
"_geoDistance":4548
},
{
"id":"4",
"_geo":{
"lat":48.22919,
"lng":16.3679401
},
"_geoDistance":3938
}
],
"nbHits":4,
"exhaustiveNbHits":false,
"query":"",
"limit":20,
"offset":0,
"processingTimeMs":0
}
Which is wrong since the object with ID 3 is returned before the one with ID 4, although it's further away.
Expected behavior
Expected output would be:
- ID 1, Distance: 2717
- ID 2, Distance: 3556
- ID 4, Distance: 3938
- ID 3, Distance: 4548
MeiliSearch version: 0.23.1
EDIT from @irevoire
Steps to REALLY sort the documents by geo distances.
- Fix the bug in milli: Store the geopoint in three dimensions milli#424
- Release milli
- Integrate the new version of milli into MeiliSearch
Metadata
Metadata
Assignees
Labels
bugmilliRelated to the milli workspaceRelated to the milli workspacev0.26.0PRs/issues solved in v0.26.0PRs/issues solved in v0.26.0