# GeoDistance return distance

**URL:** <https://discuss.elastic.co/t/geodistance-return-distance/66148>\
**Category:** Elasticsearch\
**Created:** [November 15, 2016, 6:30pm UTC](https://discuss.elastic.co/t/geodistance-return-distance/66148 "2016-11-15T18:30:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![minniek](https://avatars.discourse-cdn.com/v4/letter/m/aeb1de/32.png) [@minniek](https://discuss.elastic.co/u/minniek)\
**Post date:** [November 15, 2016, 6:30pm UTC](https://discuss.elastic.co/t/geodistance-return-distance/66148/1 "2016-11-15T18:30:52Z")

</div>

I am looking to remove one of the geoDistance conditions but I want to get the distance between the to point compared. How can I include a script inside a query?  
Thanks

curl -XGET '[http://127.0.0.1:9200/testigoshaya/\_search](http://127.0.0.1:9200/testigoshaya/_search)' -d '  
{  
"fields" : ["\_source"],  
"query":  
{"bool":  
{"must": [  
{ "match": { "type\_c": "RES"}} ,  
{ "match": { "font": "dfg"}} ,  
{ "range" : { "superficie" : { "from" : "10", "to" :"50" } } }  
]  
,"filter" : {"geo\_distance" :  
{ "distance" : "2km",  
"location" : { "lat" : 41.560689200000000,  
"lon" : 1.999436000000059  
}  
}  
}  
}  
},

```
       "script_fields" : {
              "distance" : {
                 "params" : {
                    "lat" : 41.560689200000000,
                    "lon" : 1.999436000000059
                 },
             "script" : "doc[\u0027location\u0027].distanceInKm(lat,lon)"
              }
       }  
     }'
```

---

<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:** [December 13, 2016, 6:31pm UTC](https://discuss.elastic.co/t/geodistance-return-distance/66148/2 "2016-12-13T18:31:34Z")

</div>

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