mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-22 21:05:23 +00:00
[Doc] Updated docs for distance scripting
Updated docs for distance scripting and added missing geohash distance functions Closes #5397
This commit is contained in:
parent
0cd184ef3c
commit
c0a092aa92
@ -192,7 +192,14 @@ km) of this geo point field from the provided lat/lon with a default value.
|
||||
|
||||
|`doc['field_name'].factorDistance(lat, lon, default)` |The distance factor of this geo point field from the provided lat/lon with a default value.
|
||||
|
||||
|`doc['field_name'].geohashDistance(geohash)` |The `arc` distance (in meters)
|
||||
of this geo point field from the provided geohash.
|
||||
|
||||
|`doc['field_name'].geohashDistanceInKm(geohash)` |The `arc` distance (in km)
|
||||
of this geo point field from the provided geohash.
|
||||
|
||||
|`doc['field_name'].geohashDistanceInMiles(geohash)` |The `arc` distance (in
|
||||
miles) of this geo point field from the provided geohash.
|
||||
|=======================================================================
|
||||
|
||||
[float]
|
||||
|
@ -411,5 +411,24 @@ public abstract class ScriptDocValues {
|
||||
GeoPoint point = getValue();
|
||||
return GeoDistance.PLANE.calculate(point.lat(), point.lon(), lat, lon, DistanceUnit.MILES);
|
||||
}
|
||||
|
||||
public double geohashDistance(String geohash) {
|
||||
GeoPoint point = getValue();
|
||||
GeoPoint p = new GeoPoint().resetFromGeoHash(geohash);
|
||||
return GeoDistance.ARC.calculate(point.lat(), point.lon(), p.lat(), p.lon(), DistanceUnit.DEFAULT);
|
||||
}
|
||||
|
||||
public double geohashDistanceInKm(String geohash) {
|
||||
GeoPoint point = getValue();
|
||||
GeoPoint p = new GeoPoint().resetFromGeoHash(geohash);
|
||||
return GeoDistance.ARC.calculate(point.lat(), point.lon(), p.lat(), p.lon(), DistanceUnit.KILOMETERS);
|
||||
}
|
||||
|
||||
public double geohashDistanceInMiles(String geohash) {
|
||||
GeoPoint point = getValue();
|
||||
GeoPoint p = new GeoPoint().resetFromGeoHash(geohash);
|
||||
return GeoDistance.ARC.calculate(point.lat(), point.lon(), p.lat(), p.lon(), DistanceUnit.MILES);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user