distanceInKm not working well


#1

Hello everyone, I know I am using elasticaphp but It happened also in elasticsearch.....

I am using the class GeoDistance in order to get the location around (example : 2km )

$filter = new Elastica\Filter*GeoDistance*('location', array('lat' => $lat, 'lon' => $lng), $distance . 'km');

then, I added a script to get the distance in km ('doc[\u0027location\u0027].distanceInKm(lat,lon)')

$script = new Elastica\Script('doc[\u0027location\u0027].distanceInKm(lat,lon)', array('lat' => $lat, 'lon' => $lng));
$score->setQuery($es_bool); // other conditions (matches)
$score->setBoostMode('replace');
$score->addScriptScoreFunction($script);

So, I dont know what is going on because I got distances that are greater than 2km for a little bit for example (2,12km)

Additionally, I do not see any variable called distance or something similar but I got a variable called SCORE so i guessed that is the distance between the two geo points and I set boost to replace, Am I right?

Any ideas?
Thanks


(system) #2

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