How to select two coordinates from [x,y,z] array?

Forgive me but I am brand. spankin'. new. to Kibana and Elastic and I'm fumbling my way through my first data set.

I have a set of json documents loaded into my first elasticsearch cluster and one of the fields is a set of coordinates like this:

"geometry": {
      "type": "Point",
      "coordinates": [

which results in a number field

geometry.coordinates: -116.798, 33.515, 4.66

Can someone help me with what the scripted field looks like?

I would like to pull out the first two numbers as latitude and longitude to build a geo_point field to create a coordinate map visualization.

Hi @Agrikk!

While you could use scripted fields to technically get the data into the shape of a geo_point (e.g. something like this in Painless: [params._source.geometry.coordinates[0], params._source.geometry.coordinates[1]]), the problem you are going to run into is that the type of that field needs to be mapped to geo_point, and you can't currently do this in Kibana scripted fields.

Without that mapping in place, you aren't going to be able to visualize those coordinates on a map.

The best practice for a situation like this is modify your ingest to convert the data into the correct geo_point format. Depending on your setup there are a couple ways to do this:

  1. configure it in logstash as described in Problem converting latitude and longitude into a geo point for Kibana
  2. or to update the data you have already ingested, set up an ingest pipeline in elasticsearch and reindex as described in Reindex to add geo_point mapping

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