Unfortunately, this is not possible to do directly as a query within Algolia. However, you might be able to create a workaround by looping over the results you receive back from Algolia. Please note that this workaround has its limitations, and will probably impact the performance of your search.
When you do a geolocation search with a filter for location (this means using one of the following parameters:
insidePolygon), you will receive a
_rankingInfo.matchedGeoLocation object. This object contains the distance in meters from the location you’re trying to filter.
If you add information to each record about their travel distance (in meters), you could loop over all the hits you receive from Algolia before displaying them, and filter out all the results for which the
_rankingInfo.matchedGeoLocation.distance is bigger than the travel distance of the record.
As I said earlier, this approach does have some downsides. Let’s say you only want to display 10 results. To be sure you have at least 10 results to display, you might have to fetch more results from Algolia than you actually need. If you would only fetch the 10 results, and 3 of them have a travel distance smaller than the actual distance, you would only have 7 results to display.
On top of that, looping over all the records and not displaying certain objects has an impact on the performance of the page as well, as it will take slightly longer to display the results than normally.
I hope I understood the problem correctly and this workaround helps, good luck with the implementation!