GeoDistance return distance

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' -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)"
              }
       }  
     }'

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