# GeoDistance search with dynamic distance

**URL:** <https://discuss.elastic.co/t/geodistance-search-with-dynamic-distance/20186>\
**Category:** Elasticsearch\
**Created:** [October 10, 2014, 5:45pm UTC](https://discuss.elastic.co/t/geodistance-search-with-dynamic-distance/20186 "2014-10-10T17:45:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tom\_Miller](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tom_miller/32/774_2.png) [@Tom\_Miller](https://discuss.elastic.co/u/Tom_Miller)\
**Post date:** [October 10, 2014, 5:45pm UTC](https://discuss.elastic.co/t/geodistance-search-with-dynamic-distance/20186/1 "2014-10-10T17:45:36Z")

</div>

I have a product database, where products have a set delivery zones,  
represented in elasticsearch as an array:

[  
{  
distance: double (in miles),  
location: geohash (source location of product/seller),  
deliveryprice: double  
}  
]

does anyone have any idea how I can filter using the distance within the  
document?

I know the co-ordinates of my users, and I like to filter out products that  
don't cannot be delivered to their location - in other words, where the  
distance "double" field is greater than the distance between their  
co-ordinates and the source co-ordinates of the product.

All the examples of goedistance filtering I've seen require the distance to  
be provided in the query - not analysed from the document itself.

I'm not sure if I can use scripting to do this - if so, how?

Any help would be hugely appreciated!

Tom.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/7cc7b619-f06e-4bd4-9da0-03dbf26e3b5c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/7cc7b619-f06e-4bd4-9da0-03dbf26e3b5c%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 12:56am UTC](https://discuss.elastic.co/t/geodistance-search-with-dynamic-distance/20186/2 "2017-07-06T00:56:59Z")

</div>


