why cant we instantiate elasticsearch whitelisted classes like
def pt = org.elasticsearch.common.geo.GeoPoint.fromGeohash("a");
or
pt = new org.elasticsearch.common.geo.GeoPoint()
both of these give errors. I am trying to use this in update by query
what I really wanted to do was use the geohash to to latlon functionality present in GeoPoint Library.
I have a ctx._source.geohashes = [geohasha, geohashb ...] already indexed in a document. but we wanted to update the documents with another attribute that calculates the bounding box of those geohash arrays per document. The only way to do them is either create my on geohash to latlon function and calculate the bbox or use the GeoPoint library that already has that functionality.
The limitation i encountered was the documents are already indexed with geo_point type in geohash form so I could not get them in [lat, lon] format since there is no access to the doc in update by query only ctx
According to the Painless's API spec the GeoPoint's constructor is not available, that's why you can't instantiate (only methods getLon and getLat are available, actually).
But Elasticsearch has a Geo Bounding Box Query, can't you use that to solve your problem?
If you really need to decode the geohash into [lat, lon] then you will need to provide the function.
i see ok thank you. bbox query does not help. we wanted to preprocess bbox because it enables us to calculate things like area, longest distance an so forth.
So if you really need to decode it to [lat, lon] then one workaround, so you don't need to rewrite a geohash decode function in painless, is to write an ingest processor plugin in java, this way you have full access the Elasticsearch java's API (or any other geohash java library actually). With that custom plugin, you can reindex by referring to it from an ingest pipeline.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.