Forum Documentation Showcase Pricing Learn more

Address is within (X) kms of (Another Address)

Hi,

I’d like to add a constraint to a search for a repeating group (that displays some Users) with the “Address is within X kms of (Another Address)” filter. My problem is that I need to use a relative reference for X because in my data X is equal to the number of kilometres an User is willing to do.

Is there any way I can do this with a search?

Thanks.

Yes, X is a dynamic option. When you click on the input to set the numbers of miles/kms, a dropdown menu should show up, where you can select the value of the distance.

I know but among dropdown options I actually can’t include a dynamic option that is related to the thing I’m doing a search for. To be precise I’m doing a search for a thing called “Provider” that contains a field called “Radius” and which is a number. I’d like to display every Provider that are X (“Radius”) of an other thing’s address.

Right, in that case you should store that info in the database, and then put that entry (that contains the radius) in a group or an element state (see our last feature update). If that data is in the database, you just need a way to 1) find it, 2) reference to it.

@emmanuel
I have a follow-up question on this one that I think is relevant for this thread. Does the “within x kms” support decimals? I tried typing it into the search itself, which didn’t work, and later tried to use a dynamic decimal value, which brings this error:

image

Does this mean that it doesn’t support decimals?

Can you share a link, without that it’s hard to help.

We are encountering the same problem as - I believe - @nicolaschanton. The radius of the search is stored within the Thing searched for. Provider has a field Address and a field Servicing Distance. Now I want to show a list of Providers which are within (their) Servicing Distance of a user-provided location.
Is this kind of query possible with Bubble?

I looked for some documentation and this query seems to require a different data type in elasticsearch:

I happened upon this same issue, and this thread as a result, and figured I’d post my workaround in case anyone else was dealing with this. Here’s what worked for me:

Instead of trying to do this within a search (which I agree seems cannot be done in Bubble), I add a :filter onto the end of the search with the following statement (note: Thing A is both the thing being search and the source of the dynamic radius value) …

Advanced: Thing A's geolocation's distance from Thing B's geolocation <= Thing A's radius

-Ed