# Is it possible to cast script\_field type to geopoint?

**URL:** <https://discuss.elastic.co/t/is-it-possible-to-cast-script-field-type-to-geopoint/47096>\
**Category:** Elasticsearch\
**Created:** [April 12, 2016, 9:23am UTC](https://discuss.elastic.co/t/is-it-possible-to-cast-script-field-type-to-geopoint/47096 "2016-04-12T09:23:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Olalekan\_Elesin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/olalekan_elesin/32/827_2.png) [@Olalekan\_Elesin](https://discuss.elastic.co/u/Olalekan_Elesin)\
**Post date:** [April 12, 2016, 9:23am UTC](https://discuss.elastic.co/t/is-it-possible-to-cast-script-field-type-to-geopoint/47096/1 "2016-04-12T09:23:11Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![danielmitterdorfer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danielmitterdorfer/32/110510_2.png) [@danielmitterdorfer](https://discuss.elastic.co/u/danielmitterdorfer)\
**Post date:** [April 12, 2016, 11:23am UTC](https://discuss.elastic.co/t/is-it-possible-to-cast-script-field-type-to-geopoint/47096/2 "2016-04-12T11:23:29Z")

</div>

Hi,

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

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

```

Daniel

---

<div class="post-metadata">

**Author:** ![Olalekan\_Elesin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/olalekan_elesin/32/827_2.png) [@Olalekan\_Elesin](https://discuss.elastic.co/u/Olalekan_Elesin)\
**Post date:** [April 12, 2016, 11:48am UTC](https://discuss.elastic.co/t/is-it-possible-to-cast-script-field-type-to-geopoint/47096/3 "2016-04-12T11:48:24Z")

</div>

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;

---

<div class="post-metadata">

**Author:** ![danielmitterdorfer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danielmitterdorfer/32/110510_2.png) [@danielmitterdorfer](https://discuss.elastic.co/u/danielmitterdorfer)\
**Post date:** [April 12, 2016, 1:00pm UTC](https://discuss.elastic.co/t/is-it-possible-to-cast-script-field-type-to-geopoint/47096/4 "2016-04-12T13:00:12Z")

</div>

Hi,

you should [customize the classloader whitelist](https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting-security.html#_customising_the_classloader_whitelist) to include `org.elasticsearch.common.geo.GeoDistance`.

Daniel

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 11:00pm UTC](https://discuss.elastic.co/t/is-it-possible-to-cast-script-field-type-to-geopoint/47096/5 "2017-07-05T23:00:10Z")

</div>


