GeoLoc by IP no result?

Hi,

What happens if Algolia can’t find lat/long from aroundLatLngViaIP parameter?

Do we get empty search result or we can provide a default long/lat when that happens.

Thanks

Hello,

If no results are found close to the IP, the engine will keep searching further and further until it got enough results. It means that technically, you’ll never have empty results as at least one of your records will be considered the closest (even if it’s very far away).

If you add other limiting factors, like a search query, a bounding box or a maximum radius, it is possible that no results are found at all, in that case you’ll get an empty search result.

If you want to revert to search around a specific lat/lng when that happens, you cannot do it directly at the API level. You’ll have to intercept the results in your front-end, check if it’s empty, and if so initiate another request with your lat/lng through the aroundLatLng option.

Hope that helps :slight_smile: