# Create geo\_points using script fields

**URL:** <https://discuss.elastic.co/t/create-geo-points-using-script-fields/204630>\
**Category:** Kibana\
**Created:** [October 22, 2019, 10:44am UTC](https://discuss.elastic.co/t/create-geo-points-using-script-fields/204630 "2019-10-22T10:44:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![AstroSlazak](https://avatars.discourse-cdn.com/v4/letter/a/bbce88/32.png) [@AstroSlazak](https://discuss.elastic.co/u/AstroSlazak)\
**Post date:** [October 22, 2019, 10:44am UTC](https://discuss.elastic.co/t/create-geo-points-using-script-fields/204630/1 "2019-10-22T10:44:40Z")

</div>

Hi,

I'm working on problem where i get a message:  
"DateTime:22.10.2019 10.24.15,Longitude:10,3315497,Latitude:63,3504556,Bearing:0" and trying to get location from it and show it on map. But now i have a problem, i am able to get the longitude and the latitude but i dont know how to show them on map. Anyone has any idea ?

This is my script

String s = doc['message.keyword'].value.replace(",",".");  
def lon = /(?\<=Longitude:)(._)(?=.Latitude:)/.matcher(s);  
def lat = /(?\<=.Latitude:)(._)(?=.Bearing:)/.matcher(s);  
if (lon.find()) {

return lon.group()  
}

---

<div class="post-metadata">

**Author:** ![bhavyarm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bhavyarm/32/22392_2.png) [@bhavyarm](https://discuss.elastic.co/u/bhavyarm)\
**Post date:** [October 22, 2019, 1:52pm UTC](https://discuss.elastic.co/t/create-geo-points-using-script-fields/204630/2 "2019-10-22T13:52:24Z")

</div>

Hello,

You need to ingest geoip data to make this work. This should help:

> [@Kibana not visualizing geoip in coordinate map](https://discuss.elastic.co/t/kibana-not-visualizing-geoip-in-coordinate-map/204635):
>
> Hi, I'm having trouble visualizing my sysmon DNS logs with GeoIP resolved location on coordinate map in kibana. Following info is being added by geoip to each log entry: [logs\_fields] so it looks like longtitude and latitude is added, but so called destination\_geo.location itself isn't there. index mapping contains following: "destination" : { "properties" : { "address" : { "type" : "keyword", "ignore\_above" : 1024 }, "bytes" : { …

Thanks,  
Bhavya

---

<div class="post-metadata">

**Author:** ![wylie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wylie/32/81794_2.png) [@wylie](https://discuss.elastic.co/u/wylie)\
**Post date:** [October 22, 2019, 4:57pm UTC](https://discuss.elastic.co/t/create-geo-points-using-script-fields/204630/3 "2019-10-22T16:57:44Z")

</div>

Right, geo fields can't be used dynamically via scripted fields. They need to be available in the mapping of the index.

---

<div class="post-metadata">

**Author:** ![AstroSlazak](https://avatars.discourse-cdn.com/v4/letter/a/bbce88/32.png) [@AstroSlazak](https://discuss.elastic.co/u/AstroSlazak)\
**Post date:** [October 23, 2019, 7:47am UTC](https://discuss.elastic.co/t/create-geo-points-using-script-fields/204630/4 "2019-10-23T07:47:55Z")

</div>

OK i created a geo\_point - HFPSlocation and now i want to input extracted data from messeage to it , but i got nothing ☹

```
DELETE _ingest/pipeline/HFPSLocation
PUT _ingest/pipeline/HFPSLocation
{
"description": "use index:rti-logstash",
"processors": [
{
 "script": {
   "source": """if (ctx.message.size() !== 0){
     if (ctx.service.name == "HFPS") {
         String s = ctx.message.replace(",",".");
         def lon = /(?<=Longitude:)(.*)(?=.Latitude:)/.matcher(s);
         def lat = /(?<=.Latitude:)(.*)(?=.Bearing:)/.matcher(s);
       if (lon.find() & lat.find()){
         ctx.HFPSLongitude = lon.group();
         ctx.HFPSLatitude = lat.group();
       }}}"""
  }
 }
 ,{ "set": {
  "field": "HFPSlocation",
  "value": "{{ctx.HFPSLatitude}},{{ctx.HFPSLatitude}}"
 }
 }
]
}
```

---

<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:** [November 20, 2019, 7:47am UTC](https://discuss.elastic.co/t/create-geo-points-using-script-fields/204630/5 "2019-11-20T07:47:59Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
