Union search for geo location

Geosearch: we are trying to do the following : Service Provider Enters their location and radius that they are willing to serve. E.g. 2 Miles from 725 5th Ave, New York, NY 10022

Customer will also enter specific address e.g. 608 Madison, Brooklyn NY 11221. If this location is within the range that service provider services, it should come up in search. If it falls outside, then it would not.

Can Algolia achieve this? Any help and thoughts would be much appreciated.

Hello Pawel,

Thank you for contacting us. I understand that you want to perform a geo-located search, centered around a specific radius, and only return the results if a second address is within the radius.

Algolia doesn’t provide an out-of-the-box solution for your use-case. However, it should be achievable by doing the following:

  • Get the lat/long coordinates for your Service Provider location
  • Get the lat/long coordinates for your Customer location
  • Compute the distance between the two locations
  • If the distance is lower than the given Service Provider radius, perform the Algolia request with the aroundRadius parameter around your Service Provider location

It’s a bit manual but it’s the easiest way I can think of. Plus it prevents you from performing extra calls to Algolia when it’s not needed.

Would it suit your needs?

Thank you for your help. I am discussing it with my team.