i have restaurants collection in my redis DB, the restaurant object stored in as bellow:
{
uid: "T8957Ixo1kRjtw3Nof3Ttase",
name: "Restaurant name",
address:
"751 S 10th St, Philadelphia, Pennsylvania 19140, United States",
location: "-78.15096902,38.94039013",
}
i wonder if it possible to return results sorted by distance
i tried to do FT.SEARCH index "@name:%%burger%% @location:[-75.153270 39.949655]" SORTBY location ASC
but it doesn't work at all, How can I achieve that by redisearch?
Currently, this is only possible with
FT.AGGREGATE. You will have to useAPPLY(documentation here), and then sort by it.Try something like:
There are some other overloading for
geodistancein the documentation, you can use the one that suits your environment best.In addition, you should take another look at the GEO filter syntax. Your query is invalid:
The query I suggested will work, but if you can give a relevant radius to look in, you might get better performance.
for example:
will limit the search to a 5km radius.
Hope that helps!