algoliasearch-helper-js
algoliasearch-helper-js copied to clipboard
How to combine insideBoundingBox and aroundLatLng
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!
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 :)
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/
boundingBoxparam - sorting
objectIDsfrom result
query2
- w/
aroundLatLngparam (automatic radius, sorted by distance) - w/ a
facetRefinement, restricting result to theobjectIDsfromquery1
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 Yep!
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 :)
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.
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.
@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.