why cant we instantiate elasticsearch whitelisted classes like
def pt = org.elasticsearch.common.geo.GeoPoint.fromGeohash("a");
pt = new org.elasticsearch.common.geo.GeoPoint()
both of these give errors. I am trying to use this in update by query
There shouldn't be a need to instantiate that class in an update by query. Can you share the update by queyr request that you are trying to execute?
thanks for the reply.
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
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.
Here is a sample ingest processor plugin: https://github.com/elastic/elasticsearch/tree/master/plugins/ingest-attachment
oo thanks. that will work. thank you
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.