Is it possible to cast script_field type to geopoint?

In a file script, I have this:

def locationGeoData = [:]
locationGeoData['port'] = [4.815554, 7.0498442]
locationGeoData['harcourt'] = [4.815554, 7.0498442]
locationGeoData[doc['region'].value]

Is it possible to convert the return type to geopoint so I can use it in plotting maps in Kibana

Hi,

can't you just create a GeoPoint instance? For example:

locationGeoData['port'] = new org.elasticsearch.common.geo.Geopoint(4.815554, 7.0498442)

Daniel

Thanks Daniel. i tried that just now and I got this:

at org.elasticsearch.script.groovy.GroovyScriptEngineService.compile(GroovyScriptEngineService.java:198)
at org.elasticsearch.script.ScriptService$ScriptChangesListener.onFileInit(ScriptService.java:549)
at org.elasticsearch.script.ScriptService$ScriptChangesListener.onFileChanged(ScriptService.java:580)
at org.elasticsearch.watcher.FileWatcher$FileObserver.onFileChanged(FileWatcher.java:279)
at org.elasticsearch.watcher.FileWatcher$FileObserver.checkAndNotify(FileWatcher.java:131)
at org.elasticsearch.watcher.FileWatcher$FileObserver.updateChildren(FileWatcher.java:215)
at org.elasticsearch.watcher.FileWatcher$FileObserver.checkAndNotify(FileWatcher.java:117)
at org.elasticsearch.watcher.FileWatcher.doCheckAndNotify(FileWatcher.java:70)
at org.elasticsearch.watcher.AbstractResourceWatcher.checkAndNotify(AbstractResourceWatcher.java:44)
at org.elasticsearch.watcher.ResourceWatcherService$ResourceMonitor.run(ResourceWatcherService.java:187)
at org.elasticsearch.threadpool.ThreadPool$LoggingRunnable.run(ThreadPool.java:640)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
e113fb6c0e4865d43a74afad362843e5d78e47e4: 1: unable to resolve class org.elasticsearch.common.geo.GeoDistance
@ line 1, column 1.
import org.elasticsearch.common.geo.GeoDistance;

Hi,

you should customize the classloader whitelist to include org.elasticsearch.common.geo.GeoDistance.

Daniel