# SOLVED - Long & Lat Help - I've been reading many posts & still no answers

**URL:** https://discuss.elastic.co/t/solved-long-lat-help-ive-been-reading-many-posts-still-no-answers/122137
**Category:** Logstash
**Created:** [March 1, 2018, 5:46pm UTC](https://discuss.elastic.co/t/solved-long-lat-help-ive-been-reading-many-posts-still-no-answers/122137 "2018-03-01T17:46:30Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![Wayne\_Taylor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wayne_taylor/32/45984_2.png) [@Wayne\_Taylor](https://discuss.elastic.co/u/Wayne_Taylor)
#### Post date: [March 1, 2018, 5:46pm UTC](https://discuss.elastic.co/t/solved-long-lat-help-ive-been-reading-many-posts-still-no-answers/122137/1 "2018-03-01T17:46:31Z")

</div>

Team,

My data source has Longtitude and Latitude in it. I have time series data of aircraft and want to plot the map progress.

I am using Logstash 5.3.0 from an event stream. Below is my configuration. Currently when the data is ingested into Elasticsearch its still showing as String (1st attempt), Numeric (2nd attempt and many after that). I want to get to a point I can use maps in Kibana.

Filter Section:

```
mutate {
  convert => { "longitude" => "float" }
  convert => { "latitude" => "float" }
}
    
mutate {
  add_field => { "[location][lat]" => "%{latitude}" }
  add_field => { "[location][lon]" => "%{longitude}" }
}
            
date {
  match => ["time_at_position", UNIX_MS]
  target => "@timestamp"
}

```

My Output Section (excluded user details and host:

```
elasticsearch {
  index => "flightpostest"
  document_type => "positional"
  manage_template => "false"
  template_name => "positional"
}

```

My Template:

```
PUT _template/positional
{
  "template": "positional*",
  "settings": {},
  "mappings": {
    "_default_": {
      "properties": {
        "location": {
          "type": "geo_point"
        }
      }
    }
  }
}

```

What am I missing to get this as a Geo Point so I can use Maps. I've read this: [https://www.elastic.co/guide/en/elasticsearch/reference/current/geo-point.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/geo-point.html)  
and the engineering post and blog but still stumped.

Please help.

Wayne

---

<div class="post-metadata">

### Author: ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)
#### Post date: [March 1, 2018, 7:22pm UTC](https://discuss.elastic.co/t/solved-long-lat-help-ive-been-reading-many-posts-still-no-answers/122137/2 "2018-03-01T19:22:02Z")

</div>

Doing the convert of longitude and latitude has no effect on the geo\_point. add\_field converts them back to string. You could do a convert on "[location][lat]" but you do not need to. geo\_point will work with either string or float.

Get rid of the template and create the index using

```auto
PUT flightpostest
{
  "mappings": {
    "doc": {
      "properties": {
        "location": {
          "type": "geo_point"
        }
      }
    }
  }
}

```

Then in your output just name the index

```auto
elasticsearch {
index => "flightpostest"
hosts => ["localhost"]
}

```

---

<div class="post-metadata">

### Author: ![Wayne\_Taylor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wayne_taylor/32/45984_2.png) [@Wayne\_Taylor](https://discuss.elastic.co/u/Wayne_Taylor)
#### Post date: [March 1, 2018, 11:18pm UTC](https://discuss.elastic.co/t/solved-long-lat-help-ive-been-reading-many-posts-still-no-answers/122137/3 "2018-03-01T23:18:51Z")

</div>

@Badger - I made the changes as per suggestion and now getting the following exception:

> [2018-03-01T23:17:27,421][WARN][logstash.outputs.elasticsearch] Could not index event to Elasticsearch. {:status=\>400, :action=\>["index", {:\_id=\>nil, :\_index=\>"flightpostest", :\_type=\>"positional", :\_routing=\>nil}, #LogStash::Event:0x7cda5271], :response=\>{"index"=\>{"\_index"=\>"flightpostest", "\_type"=\>"positional", "\_id"=\>"AWHj2yweXQkqogeoXm0O", "status"=\>400, "error"=\>{"type"=\>"illegal\_argument\_exception", "reason"=\>"[location] is defined as an object in mapping [positional] but this name is already used for a field in other types"}}}}

---

<div class="post-metadata">

### Author: ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)
#### Post date: [March 2, 2018, 1:54am UTC](https://discuss.elastic.co/t/solved-long-lat-help-ive-been-reading-many-posts-still-no-answers/122137/4 "2018-03-02T01:54:18Z")

</div>

> [@Wayne\_Taylor](#):
>
> now getting the following exception

🙂 I banged my head on that one for a while. Did you delete the template that you previously added? I think that is what fixed it for me.

---

<div class="post-metadata">

### Author: ![Wayne\_Taylor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wayne_taylor/32/45984_2.png) [@Wayne\_Taylor](https://discuss.elastic.co/u/Wayne_Taylor)
#### Post date: [March 2, 2018, 3:08am UTC](https://discuss.elastic.co/t/solved-long-lat-help-ive-been-reading-many-posts-still-no-answers/122137/5 "2018-03-02T03:08:25Z")

</div>

@Badger - error gone now but back to strings :(.

 ![23%20PM](https://us1.discourse-cdn.com/elastic/original/3X/6/1/610872012ceee1f7a2d2075a3d1c68ddef80ca79.png)

---

<div class="post-metadata">

### Author: ![wwalker](https://avatars.discourse-cdn.com/v4/letter/w/43a26b/32.png) [@wwalker](https://discuss.elastic.co/u/wwalker)
#### Post date: [March 2, 2018, 6:53am UTC](https://discuss.elastic.co/t/solved-long-lat-help-ive-been-reading-many-posts-still-no-answers/122137/6 "2018-03-02T06:53:40Z")

</div>

Throw my two cents in here. Instead of expressing my geo\_point as an object, I have it configured as a string, example 2 in the [reference manual](https://www.elastic.co/guide/en/elasticsearch/reference/current/geo-point.html). You may want to give it a shot, if you haven't already, it appears as though it may be a lot less work for your pipeline.

`add_field => { "[geoip][location][coordinates]" => "%{[geoip][location][lat]}, %{[geoip][location][lon]}" }`

Just to be clear, my field names are geoip.location.coordinates, geoip.location.lat, and geoip.location.lon; hence the reason for all the extra brackets...can be confusing if you've never encountered it before.

---

<div class="post-metadata">

### Author: ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)
#### Post date: [March 2, 2018, 6:05pm UTC](https://discuss.elastic.co/t/solved-long-lat-help-ive-been-reading-many-posts-still-no-answers/122137/7 "2018-03-02T18:05:53Z")

</div>

If I create an index using

```
PUT differentname
{
  "mappings": {
    "doc": {
      "properties": {
        "location": {
          "type": "geo_point"
        }
      }
    }
  }
}
```

and populate it using this

```
input { generator { message => '{ "longitude" : -1.2 , "latitude" : 3.45, "t": 1492310893103, "foo" : 1 }' count => 1 } }
output { stdout { codec => rubydebug } }
filter {
  json { source => "message" }
  mutate {
    add_field => { "[location][lat]" => "%{latitude}" }
    add_field => { "[location][lon]" => "%{longitude}" }
  }
                
  date {
    match => ["t", UNIX_MS]
    target => "@timestamp"
  }
}
output {
  elasticsearch {
    index => "differentname"
    hosts => ["localhost"]
  }
}
```

then I get a geo\_point. Does that work for you, or do you still get the conflict?

![AA1](https://us1.discourse-cdn.com/elastic/original/3X/b/1/b1e7f8c84d520a8dfd2c956c95b6f39df81fdbbd.png)

---

<div class="post-metadata">

### Author: ![Wayne\_Taylor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wayne_taylor/32/45984_2.png) [@Wayne\_Taylor](https://discuss.elastic.co/u/Wayne_Taylor)
#### Post date: [March 2, 2018, 6:35pm UTC](https://discuss.elastic.co/t/solved-long-lat-help-ive-been-reading-many-posts-still-no-answers/122137/8 "2018-03-02T18:35:35Z")

</div>

@Badger - i get conflict ☹

> [2018-03-02T18:34:38,900][WARN][logstash.outputs.elasticsearch] Could not index event to Elasticsearch. {:status=\>400, :action=\>["index", {:\_id=\>nil, :\_index=\>"positional", :\_type=\>"positional", :\_routing=\>nil}, #LogStash::Event:0x76c34393], :response=\>{"index"=\>{"\_index"=\>"positional", "\_type"=\>"positional", "\_id"=\>"AWHn\_p2lXQkqogeocS\_l", "status"=\>400, "error"=\>{"type"=\>"illegal\_argument\_exception", "reason"=\>"[location] is defined as an object in mapping [positional] but this name is already used for a field in other types"}}}}

---

<div class="post-metadata">

### Author: ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)
#### Post date: [March 2, 2018, 6:42pm UTC](https://discuss.elastic.co/t/solved-long-lat-help-ive-been-reading-many-posts-still-no-answers/122137/9 "2018-03-02T18:42:42Z")

</div>

You used the index positional. Don't do that. Using the index name differentname was the point 🙂

---

<div class="post-metadata">

### Author: ![Wayne\_Taylor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wayne_taylor/32/45984_2.png) [@Wayne\_Taylor](https://discuss.elastic.co/u/Wayne_Taylor)
#### Post date: [March 2, 2018, 7:05pm UTC](https://discuss.elastic.co/t/solved-long-lat-help-ive-been-reading-many-posts-still-no-answers/122137/10 "2018-03-02T19:05:22Z")

</div>

Ok - but same issue 🙂

> 2018-03-02T19:04:17,379][WARN][logstash.outputs.elasticsearch] Could not index event to Elasticsearch. {:status=\>400, :action=\>["index", {:\_id=\>nil, :\_index=\>"differentname", :\_type=\>"GPS\_EVENT", :\_routing=\>nil}, #LogStash::Event:0x228da33f], :response=\>{"index"=\>{"\_index"=\>"differentname", "\_type"=\>"GPS\_EVENT", "\_id"=\>"AWHoGcAxXQkqogeocayS", "status"=\>400, "error"=\>{"type"=\>"illegal\_argument\_exception", "reason"=\>"[location] is defined as an object in mapping [GPS\_EVENT] but this name is already used for a field in other types"}}}}  
> [2018-03-02T19:04:17,881][INFO][logstash.pipeline] Pipeline has terminated {:pipeline\_id=\>"main", :thread=\>"#\<Thread:0x5495491d run\>"}  
> [

Why is this difficult ☹

---

<div class="post-metadata">

### Author: ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)
#### Post date: [March 2, 2018, 7:31pm UTC](https://discuss.elastic.co/t/solved-long-lat-help-ive-been-reading-many-posts-still-no-answers/122137/11 "2018-03-02T19:31:35Z")

</div>

> [@Wayne\_Taylor](#):
>
> Ok - but same issue

Then I am out of ideas. Sorry.

---

<div class="post-metadata">

### Author: ![Wayne\_Taylor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wayne_taylor/32/45984_2.png) [@Wayne\_Taylor](https://discuss.elastic.co/u/Wayne_Taylor)
#### Post date: [March 3, 2018, 2:46am UTC](https://discuss.elastic.co/t/solved-long-lat-help-ive-been-reading-many-posts-still-no-answers/122137/12 "2018-03-03T02:46:45Z")

</div>

alright @Badger - got it working. It bugged the crap out of my that your dummy sample worked - but didn't work with my real config. I then did a lot of forum searching on the error message returned now and found this: [Errors with geo\_point](https://discuss.elastic.co/t/errors-with-geo-point/60904/3).

From that, deleted my old index, put my mapping and then ingested and boom 🙂

What a pain in the ass.

Thank you so much for helping.

---

<div class="post-metadata">

### Author: ![hbj](https://avatars.discourse-cdn.com/v4/letter/h/67e7ee/32.png) [@hbj](https://discuss.elastic.co/u/hbj)
#### Post date: [March 13, 2018, 8:03am UTC](https://discuss.elastic.co/t/solved-long-lat-help-ive-been-reading-many-posts-still-no-answers/122137/13 "2018-03-13T08:03:06Z")

</div>

This is very interesting.

@Wayne_Taylor Could you share a sample of your input and your final config?

Very curios to see what the output looks like. I'm wanting to do the same - i.e. plot aircraft and/or even generate heatmaps.

---

<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: [April 10, 2018, 8:03am UTC](https://discuss.elastic.co/t/solved-long-lat-help-ive-been-reading-many-posts-still-no-answers/122137/14 "2018-04-10T08:03:11Z")

</div>

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