Query filter with variable geo_distance

I have an interesting situation. I am building an app where sellers post items with geo_point and market_radius field. The market_radius field determines how far the seller can entertain a buyer. if seller says he/she will only entertain buyers from within 80km then the buyers further than 80km will never see the item.

is it possible to filter results by a variable geo_distance?

image

I want the value of geo_distance be coming from a document rather than fixed value.

I may be misunderstanding your setup, but distance is what you specify, so you can change it to whatever you want. Is the example you are showing from your code, or are you using a script there?

Also please don't post pictures of text, they are difficult to read, impossible to search, difficult to replicate, and some people may not be even able to see them :slight_smile:

As you know these values when you index the document, why don’t you index a geo shape representing the area the product is available in and then search for shapes that include the location of the buyer?

1 Like

it is just for presentation of what I am trying to achieve. I needed the part on red arrow to be a data coming from the document. it is not a working code because it is not possible. sorry

actually, I think this is the solution. I will try it. :slight_smile: thanks a lot man!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.