Create geo_points using script fields

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()
}

Hello,

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

Thanks,
Bhavya

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

OK i created a geo_point - HFPSlocation and now i want to input extracted data from messeage to it , but i got nothing :frowning:

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}}"
 }
 }
]
}

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