Hi,
I have a painless script, it iterate over a set of geopoints and compute the shortest distance.
But it seems that there is an error:
"script_fields": {
"distance": {
"script": {
"source": "double d = Double.MAX_VALUE; for (gp in doc['geoLocations']) d = Math.min(d, gp.planeDistance(params.lat,params.lon) * 0.001); return d;",
"lang": "painless",
"params": {
"lat": {{latitude}},
"lon": {{longitude}}
}
}
}
Here is the error message:
"reason": "dynamic method [org.elasticsearch.common.geo.GeoPoint, planeDistance/2] not found"
I have checked my mapping and I have this:
"geoLocations": {
"type": "geo_point"
}
So, if someone has an idea of the issue ?
Thanks
spinscale
(Alexander Reelsen)
August 12, 2020, 8:54am
2
I quickly peeked into the source, and you should have a method like doc['geoLocations'].planeDistance(lat, lon)
...
hope this helps!
Thanks, but the problem with this solution is that it only use the first geopoints, I'm looking for the closest one.
spinscale
(Alexander Reelsen)
August 12, 2020, 9:05am
4
Indeed. feel free to open a feature report in github.
Just to make sure I understand the problem space fully: Can you send an additional search request and sort by geo distance instead of using a script? Do you have to use scripting here?
See https://www.elastic.co/guide/en/elasticsearch/reference/7.8/sort-search-results.html#geo-sorting
Thanks for your suggestion,
Such request exist since a long time, see:
opened 04:19PM - 19 Jul 17 UTC
closed 03:26PM - 24 May 18 UTC
>bug
:Analytics/Geo
It will be really confortable to allow call to arcDistance from GeoPoint. Indeed… actually we can only call them from GeoPoints (and that will use only the first point).
In the current situation, the script is necessary... it allows me to generate fields for debugging my DSL ! I will remove it in production.
It is to debug another query, that use distance_feature (That I can't make it work):
Hi,
Imagine I have 3 queries:
"distance_feature": { ... time... }
"distance_feature": { ... location... }
"dis_max" : { ... }
Currently, to combine it I do this:
"query" : {
"bool" : {
"must" : [
"distance_feature": { ... time... },
"distance_feature": { ... location... },
"dis_max" : { ... },
]
}
}
The problem is that the score of computes as a sum, and I'm looking for a way to "multiply" instead.
I have try with function score, but I can't put them there, right ?
Do y…
My sorting is based on multiples criterions... not only the distance.
But anyway, I suspect that I should use it in my query... (I don't like this, but maybe there are no other choices).
BTW, I can request the feature on GitHub, but the problem is that I need something asap to enter in production, you see
system
(system)
Closed
September 9, 2020, 9:46am
7
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.