algoliasearch-helper-js icon indicating copy to clipboard operation
algoliasearch-helper-js copied to clipboard

How to combine insideBoundingBox and aroundLatLng

Open timkelty opened this issue 8 years ago • 8 comments

The docs state specifically that you can't do this:

This feature only filters the records and doesn’t have any impact on the ranking of results. However, it cannot be used along with aroundLatLng/aroundLatLngViaIP. Those parameters will be ignored when using a bounding box.

Naturally, this is exactly what the client wants :)

I want to filter out results outside of the boundingBox, while still ordering closest to my center point.

I can imagine possibly achieving this with 2 queries, but that seems wasteful.

If there is any way to pull this off I'd be interested, otherwise consider it a FR!

timkelty avatar Mar 15 '17 12:03 timkelty

Doing a bit of long due review of the issues here :) Sorry for the lag.

What do you mean "otherwise consider it a FR!"? Anyway if the docs says so :) Also if you have a way to do it with multiple requests that would be awesome to share it with us :)

bobylito avatar Jun 08 '17 07:06 bobylito

NP, sorry for being vague.

I just meant to propose a feature request that removes the restriction stated in the docs.

Also if you have a way to do it with multiple requests that would be awesome to share it with us

I didn't end up implementing this, but my plan was to do something like:

query1

  • w/ boundingBox param
  • sorting objectIDs from result

query2

  • w/ aroundLatLng param (automatic radius, sorted by distance)
  • w/ a facetRefinement, restricting result to the objectIDs from query1

timkelty avatar Jun 08 '17 11:06 timkelty

So the idea here is to implement a new feature that would aggregate the boundingBox and aroundLatLng? The same way disjunctive faceting does mutliple query, but as far the user is concerned it's a single option?

bobylito avatar Jun 08 '17 21:06 bobylito

@bobylito Yep!

timkelty avatar Jun 08 '17 22:06 timkelty

Ok thanks, that's really something I want to explore more: the idea of the JS Helper as the gateway to experiment with complex features that we don't want to move to the engine. We'll have to check back with the backend team though :)

bobylito avatar Jun 08 '17 22:06 bobylito

Resurrecting this. Were you able to get to a solution for your issue? I have the same problem here and there still doesn't seem to be a way to achieve it.

mathg avatar Feb 11 '20 14:02 mathg

I think this issue is more related to the engine than the helper. Do you want the same behaviour as Tim described? ie Bounding box filtering and aroundLatLng ordering?

An option which is possible, but only when the result set is small enough, is to do a query for all the items in the bounding box, and manually sorting them based on the geo location.

Haroenv avatar Feb 11 '20 14:02 Haroenv

@mathg nope - I decided it wasn't worth making 2 requests as described, and convinced the client the same :)

Still would be a nice feature though.

timkelty avatar Feb 11 '20 19:02 timkelty