Add results when use geolocation

Hello,

I’m running into a use case where customers can search base on geolocation.
Our store allow people to buy online item or push item to make drive to store.

In fact we have items with geoloc and items without.

I would like to push online items when a customer search for geolocation but can’t find away to do this in a single request.

If I understand well, geolocation works like a filter, however if I add an other filter (for example “online = 1 OR store = 1”, results are already filtered by geolocation so it doesn’t work.

An other idea is to push online item, with Rules. If a customer use geolocation, we add online items. I can’t find a way to do this in Rules.

Is this something possible ? Any help on this ?

Have a nice day,

Hi @stanislas, Indeed it is not possible to add an OR condition within a Geofilter like you describe.

Behind the scenes, the geosearch widget is using aroundLatLng to filter for the locations that are within the search area: Filter Results Around a Location | How to | Managing Results | Guide | Algolia Documentation

This means that only results falling within this area are returned.

Therefore if you want to also show results that are not within this area, then you will need to make a separate search without the geographic restriction in it to fetch the “online” results.

We have details of how you can build such a multi index search here: Multi Index Search | Building Search UI | Guide | Algolia Documentation

I have built an example for you showing this in action with a geosearch here: Multi index search with a map (exclude some results from geo filter) - CodeSandbox

We basically combine the steps for a normal geosearch, with the steps for a multi index search so that one of our searches is a geo search and the other is not.