Suggestions on ways to improve location search element

At the moment I have a form on the frontend which consists of a query field, categories and location. The location search is using Google Places API to get the lat/lng to send as part of the Algolia search.

One key issue at the moment is when a user searches for results in a country, not all the results show, due the the lat/lng of the country and the radius (fixed to 10 miles) being set may not include all the entries, as some entries will be set for that country, but outside of the radius and the center search point, which it is using for the country.

I have thought about using a distance search field in the front end form, but that does not necessarily solve the issues and count bring up results from other countries if the search radius is larger than the country.

Does anyone have any suggestions for improving this feature functionality so that when a country is selected, with no town or street, then it will return all relevant results.

One option i have thought of is to test the return from Google Place API and see if it only contains a country response, if so, search based on the address country field, rather than the geo data.
I am guessing this may not allow the results to be ordered by location though?

I have also looked through the docs for searching by country and city, from the examples for the airports, it would be good to know if this was worth exploring and testing.

Thanks for any suggestions to improve this location search.

Hi @develop,

Thank you for contacting Algolia. If you have a live website and can give us one specific example to walkthrough, including the query, results you are getting, results you would like to get (and any other details) we may be able to provide general guidance.

No guarantees though :slight_smile: At this point the request is a general implementation review and we don’t offer that, it’s very broad - you’d have to be at a plan level where you’re working with a Solutions Architect for something like this. Thanks for your understanding!

Thanks, and understood.
I guess I am just trying to get an understanding if it is possible to geo search based on boundaries rather than just a geo location.

So that all results within the boundary can be surfaced.


Hi there!

If you’re willing to return results based on a specific city or country, and not do radius-based geolocation like we provide with our geosearch feature, I would recommend adding the city and country to your records, set them as attributesForFaceting, and filter on these attributes instead.

You would have to retrieve the city and country of the current user yourself, so that you can apply the filter automatically when they search. The only downside compared to our geolocation feature is that you wouldn’t get ranking based on distance.

Does that help with what you’re trying to do?

Thanks. I think that is one possible option to look at doing.
I also think for this instance, ranking by distance won’t be needed, as searching by country would be a broad area it does not require distance in our instance.