I am not sure if this is the best way to get the distance but .... I had
to repeat the geoDistance condition because I am not able to write a
script inside a query (error: It can not recognize script_fields ) and
If I remove geo_distance it ignores the two matches and range.
Anyways
... So, I was looking to represent in elastica php something similar to
have a match , range, geo_distance and the most important thing:
(doc[\u0027location\u0027].
distanceInKm(lat,lon)) ---> my headache
Thanks
curl -XGET '
http://127.0.0.1:9200/information/_search' -d '
{
"fields" : [ "_source" ],
"query":
{"bool":
{"must": [
{ "match": { "tipos_c": "Rest"}} ,
{ "match": { "font": "yui"}} ,
{ "range" : { "sqm" : { "from" : "10", "to" :"50" } } }
]
,"filter" : {"geo_distance" :
{ "distance" : "2km",
"location" : { "lat" : 41.560689200000000,
"lon" : 1.999436000000059
}
}
}
}
},
"script_fields" : {
"location" : {
"params" : {
"lat" : 41.560689200000000,
"lon" : 1.999436000000059
},
"script" : "doc[\u0027location\u0027].distanceInKm(lat,lon)"
}
}
}'
In
my first post I could represent the range and the geoDistance but It is
not possible for me to return the distance between the two points
compared.