# Help with Geo\_point (longitude and latitude)

**URL:** <https://discuss.elastic.co/t/help-with-geo-point-longitude-and-latitude/117333>\
**Category:** Elasticsearch\
**Created:** [January 27, 2018, 9:12pm UTC](https://discuss.elastic.co/t/help-with-geo-point-longitude-and-latitude/117333 "2018-01-27T21:12:15Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Prakash\_Punj](https://avatars.discourse-cdn.com/v4/letter/p/4bbf92/32.png) [@Prakash\_Punj](https://discuss.elastic.co/u/Prakash_Punj)\
**Post date:** [January 27, 2018, 9:12pm UTC](https://discuss.elastic.co/t/help-with-geo-point-longitude-and-latitude/117333/1 "2018-01-27T21:12:16Z")

</div>

need help wiith importing Latitude and Longitude as geo\_point.

My data has longitude and latitude field

I have a conf file to pull the data to ES:

mutate {convert =\> ["latitude", "float"]}  
mutate {convert =\> ["longitude", "float"]}  
mutate {rename =\> {"longitude" =\> "[location][lon]"}}  
mutate {rename =\> {"latitude" =\> "[location][lat]"}}

I use logstash to pull the data to ES and is getting pulled without any error but I see that location.lat AND location.long showing as number not geo\_point

location.lat number   
location.lon number

As I understand after reading through few posts, I need to create mapping in ES. '

How to do that. Can I map after data is uploaded to ES ? my index name is ufo2.

Please help..

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [January 27, 2018, 9:58pm UTC](https://discuss.elastic.co/t/help-with-geo-point-longitude-and-latitude/117333/2 "2018-01-27T21:58:11Z")

</div>

Yes. Create the mapping before indexing your first document.

See [https://www.elastic.co/guide/en/elasticsearch/reference/6.1/indices-put-mapping.html](https://www.elastic.co/guide/en/elasticsearch/reference/6.1/indices-put-mapping.html)

Apply the geo point type to your field. [https://www.elastic.co/guide/en/elasticsearch/reference/6.1/geo-point.html](https://www.elastic.co/guide/en/elasticsearch/reference/6.1/geo-point.html)

---

<div class="post-metadata">

**Author:** ![Prakash\_Punj](https://avatars.discourse-cdn.com/v4/letter/p/4bbf92/32.png) [@Prakash\_Punj](https://discuss.elastic.co/u/Prakash_Punj)\
**Post date:** [February 22, 2018, 1:17am UTC](https://discuss.elastic.co/t/help-with-geo-point-longitude-and-latitude/117333/3 "2018-02-22T01:17:59Z")

</div>

Below are the steps I am taking:

Below are the steps I am following to store geo\_point

a.) Created index : PUT chicago\_crime . - THIS IS TO CREATE INDEX  
b.) Geo point mapping: - CREATE A MAPPING WITH a field location with Geo\_point Datatype  
PUT chicago\_crime/\_mapping/my\_type  
{  
"my\_type": {  
"properties": {  
"location": {  
"type": "geo\_point"  
}  
}  
}  
}

c.) logstash: - THIS IS THE LOGSTASH conf file  
input {  
file {  
path =\> "/home/ppunj/chicago-crime.csv"  
start\_position =\> 'beginning'  
sincedb\_path =\> '/dev/null'  
}  
}  
filter {  
csv {  
separator =\> ","  
columns =\> ["id","case","number","date","block","iucr","primary type","description","location description","arrest","domestic","district","ward","community area","year","latitude","longitude"]  
}  
date {  
match =\> ["date", "MM/dd/yyyy HH:mm"]  
target =\> "date"  
locale =\> "en"  
}  
mutate {convert =\> ["latitude", "float"]}  
mutate {convert =\> ["longitude", "float"]}  
mutate {  
rename =\> {  
"longitude" =\> "[location][lon]"  
"latitude" =\> "[location][lat]"  
}  
}  
}  
output {  
elasticsearch {  
hosts =\> "[http://localhost:9200](http://localhost:9200)"  
index =\> "chicago\_crime"  
}  
stdout {}  
}

d.)SAMPLE CSV file

id,case number,date,block,iucr,primary type,description,location description,arrest,domestic,district,ward,community area,year,latitude,longitude  
10000092,HY189866,3/18/2015 19:44,047XX W OHIO ST,041A,BATTERY,AGGRAVATED: HANDGUN,STREET,FALSE,FALSE,11,28,25,2015,41.89139886,-87.74438457  
10000094,HY190059,3/18/2015 23:00,066XX S MARSHFIELD AVE,4625,OTHER OFFENSE,PAROLE VIOLATION,STREET,TRUE,FALSE,7,15,67,2015,41.77337153,-87.66531947  
10000095,HY190052,3/18/2015 22:45,044XX S LAKE PARK AVE,486,BATTERY,DOMESTIC BATTERY SIMPLE,APARTMENT,FALSE,TRUE,2,4,39,2015,41.81386068,-87.59664284  
10000096,HY190054,3/18/2015 22:30,051XX S MICHIGAN AVE,460,BATTERY,SIMPLE,APARTMENT,FALSE,FALSE,2,3,40,2015,41.80080242,-87.62261934  
10000097,HY189976,3/18/2015 21:00,047XX W ADAMS ST,031A,ROBBERY,ARMED: HANDGUN,SIDEWALK,FALSE,FALSE,11,28,25,2015,41.87806476,-87.74335401

ERROR after logstash ran:

[2018-02-21T16:47:43,277][WARN][logstash.outputs.elasticsearch] Could not index event to Elasticsearch. {:status=\>400, :action=\>["index", {:\_id=\>nil, :\_index=\>"chicago\_crime", :\_type=\>"doc", :\_routing=\>nil}, #LogStash::Event:0x4bdf395e], :response=\>{"index"=\>{"\_index"=\>"chicago\_crime", "\_type"=\>"doc", "\_id"=\>"cYNWumEBzT\_mw5xoIQ6O", "status"=\>400, "error"=\>{"type"=\>"illegal\_argument\_exception", "reason"=\>"[location] is defined as an object in mapping [doc] but this name is already used for a field in other types"}}}}

what I am missing ??

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [February 22, 2018, 4:36am UTC](https://discuss.elastic.co/t/help-with-geo-point-longitude-and-latitude/117333/4 "2018-02-22T04:36:38Z")

</div>

Please format your code, logs or configuration files using `</>` icon as explained in [this guide](https://discuss.elastic.co/t/about-the-elasticsearch-category/21) and not the citation button. It will make your post more readable.

Or use markdown style like:

````
```
CODE
```

````

There's a live preview panel for exactly this reasons.

Lots of people read these forums, and many of them will simply skip over a post that is difficult to read, because it's just too large an investment of their time to try and follow a wall of badly formatted text.  
If your goal is to get an answer to your questions, it's in your interest to make it as easy to read and understand as possible.  
Please update your post.

---

<div class="post-metadata">

**Author:** ![Prakash\_Punj](https://avatars.discourse-cdn.com/v4/letter/p/4bbf92/32.png) [@Prakash\_Punj](https://discuss.elastic.co/u/Prakash_Punj)\
**Post date:** [February 23, 2018, 12:06am UTC](https://discuss.elastic.co/t/help-with-geo-point-longitude-and-latitude/117333/5 "2018-02-23T00:06:10Z")

</div>

STEP 1

```
PUT chicago_crime

```

STEP 2

```
PUT chicago_crime/_mapping/my_type 
{
"my_type": {
"properties": {
"location": {
"type": "geo_point"
}
}

```

}  
}

STEP 3 - Logstash

```
    input {
file {
path => "/home/ppunj/chicago-crime.csv"
start_position => 'beginning'
sincedb_path => '/dev/null'
}
}
filter {
csv {
separator => ","
columns => ["id","case","number","date","block","iucr","primary type","description","location description","arrest","domestic","district","ward","community area","year","latitude","longitude"]
}
date {
match => ["date", "MM/dd/yyyy HH:mm"]
target => "date"
locale => "en"
}
mutate {convert => ["latitude", "float"]}
mutate {convert => ["longitude", "float"]}
mutate {
rename => {
"longitude" => "[location][lon]"
"latitude" => "[location][lat]"
}
}
}
output {
elasticsearch {
hosts => "http://localhost:9200"
index => "chicago_crime"
}
stdout {}
}

```

SAMPLE CSV FILE

d.)SAMPLE CSV file

id,case number,date,block,iucr,primary type,description,location description,arrest,domestic,district,ward,community area,year,latitude,longitude  
10000092,HY189866,3/18/2015 19:44,047XX W OHIO ST,041A,BATTERY,AGGRAVATED: HANDGUN,STREET,FALSE,FALSE,11,28,25,2015,41.89139886,-87.74438457  
10000094,HY190059,3/18/2015 23:00,066XX S MARSHFIELD AVE,4625,OTHER OFFENSE,PAROLE VIOLATION,STREET,TRUE,FALSE,7,15,67,2015,41.77337153,-87.66531947  
10000095,HY190052,3/18/2015 22:45,044XX S LAKE PARK AVE,486,BATTERY,DOMESTIC BATTERY SIMPLE,APARTMENT,FALSE,TRUE,2,4,39,2015,41.81386068,-87.59664284  
10000096,HY190054,3/18/2015 22:30,051XX S MICHIGAN AVE,460,BATTERY,SIMPLE,APARTMENT,FALSE,FALSE,2,3,40,2015,41.80080242,-87.62261934  
10000097,HY189976,3/18/2015 21:00,047XX W ADAMS ST,031A,ROBBERY,ARMED: HANDGUN,SIDEWALK,FALSE,FALSE,11,28,25,2015,41.87806476,-87.74335401

ERROR after logstash ran:

[2018-02-21T16:47:43,277][WARN][logstash.outputs.elasticsearch] Could not index event to Elasticsearch. {:status=\>400, :action=\>["index", {:\_id=\>nil, :\_index=\>"chicago\_crime", :\_type=\>"doc", :\_routing=\>nil}, #LogStash::Event:0x4bdf395e], :response=\>{"index"=\>{"\_index"=\>"chicago\_crime", "\_type"=\>"doc", "\_id"=\>"cYNWumEBzT\_mw5xoIQ6O", "status"=\>400, "error"=\>{"type"=\>"illegal\_argument\_exception", "reason"=\>"[location] is defined as an object in mapping [doc] but this name is already used for a field in other types"}}}}

what I am missing ??

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [February 23, 2018, 4:32am UTC](https://discuss.elastic.co/t/help-with-geo-point-longitude-and-latitude/117333/6 "2018-02-23T04:32:42Z")

</div>

Can you share what gives the output stdout plugin? I'd like to see the documents that are sent to elasticsearch.

---

<div class="post-metadata">

**Author:** ![Prakash\_Punj](https://avatars.discourse-cdn.com/v4/letter/p/4bbf92/32.png) [@Prakash\_Punj](https://discuss.elastic.co/u/Prakash_Punj)\
**Post date:** [February 23, 2018, 2:53pm UTC](https://discuss.elastic.co/t/help-with-geo-point-longitude-and-latitude/117333/7 "2018-02-23T14:53:27Z")

</div>

I am using only couple of records to start with and error I am getting is:

`_**[2018-02-23T09:49:49,097][WARN][logstash.outputs.elasticsearch] Could not index event to Elasticsearch. {:status=>400, :action=>["index", {:_id=>nil, :_index=>"chicago_crime", :_type=>"doc", :_routing=>nil}, #<LogStash::Event:0x2baeadd7>], :response=>{"index"=>{"_index"=>"chicago_crime", "_type"=>"doc", "_id"=>"c4Mkw2EBzT_mw5xoPw70", "status"=>400, "error"=>{"type"=>"illegal_argument_exception", "reason"=>"[location] is defined as an object in mapping [doc] but this name is already used for a field in other types"}}}}**_`

[ppunj@EdgeNode ~]$ ./logstash-6.1.1/bin/logstash -f chicago.conf  
Sending Logstash's logs to /home/ppunj/logstash-6.1.1/logs which is now configured via log4j2.properties  
[2018-02-23T09:49:27,114][INFO][logstash.modules.scaffold] Initializing module {:module\_name=\>"netflow", :directory=\>"/home/ppunj/logstash-6.1.1/modules/netflow/configuration"}  
[2018-02-23T09:49:27,171][INFO][logstash.modules.scaffold] Initializing module {:module\_name=\>"fb\_apache", :directory=\>"/home/ppunj/logstash-6.1.1/modules/fb\_apache/configuration"}  
[2018-02-23T09:49:28,320][WARN][logstash.config.source.multilocal] Ignoring the 'pipelines.yml' file because modules or command line options are specified  
[2018-02-23T09:49:29,748][INFO][logstash.runner] Starting Logstash {"logstash.version"=\>"6.1.1"}  
[2018-02-23T09:49:30,954][INFO][logstash.agent] Successfully started Logstash API endpoint {:port=\>9600}  
[2018-02-23T09:49:43,159][INFO][logstash.outputs.elasticsearch] Elasticsearch pool URLs updated {:changes=\>{:removed=\>[], :added=\>[[http://localhost:9200/](http://localhost:9200/)]}}  
[2018-02-23T09:49:43,223][INFO][logstash.outputs.elasticsearch] Running health check to see if an Elasticsearch connection is working {:healthcheck\_url=\>[http://localhost:9200/](http://localhost:9200/), :path=\>"/"}  
[2018-02-23T09:49:43,780][WARN][logstash.outputs.elasticsearch] Restored connection to ES instance {:url=\>"[http://localhost:9200/](http://localhost:9200/)"}  
[2018-02-23T09:49:43,930][INFO][logstash.outputs.elasticsearch] ES Output version determined {:es\_version=\>nil}  
[2018-02-23T09:49:43,941][WARN][logstash.outputs.elasticsearch] Detected a 6.x and above cluster: the `type` event field won't be used to determine the document \_type {:es\_version=\>6}  
[2018-02-23T09:49:43,997][INFO][logstash.outputs.elasticsearch] Using mapping template from {:path=\>nil}  
[2018-02-23T09:49:44,064][INFO][logstash.outputs.elasticsearch] Attempting to install template {:manage\_template=\>{"template"=\>"logstash-_", "version"=\>60001, "settings"=\>{"index.refresh\_interval"=\>"5s"}, "mappings"=\>{"default"=\>{"dynamic\_templates"=\>[{"message\_field"=\>{"path\_match"=\>"message", "match\_mapping\_type"=\>"string", "mapping"=\>{"type"=\>"text", "norms"=\>false}}}, {"string\_fields"=\>{"match"=\>"_", "match\_mapping\_type"=\>"string", "mapping"=\>{"type"=\>"text", "norms"=\>false, "fields"=\>{"keyword"=\>{"type"=\>"keyword", "ignore\_above"=\>256}}}}}], "properties"=\>{"@timestamp"=\>{"type"=\>"date"}, "@version"=\>{"type"=\>"keyword"}, "geoip"=\>{"dynamic"=\>true, "properties"=\>{"ip"=\>{"type"=\>"ip"}, "location"=\>{"type"=\>"geo\_point"}, "latitude"=\>{"type"=\>"half\_float"}, "longitude"=\>{"type"=\>"half\_float"}}}}}}}}  
[2018-02-23T09:49:44,187][INFO][logstash.outputs.elasticsearch] New Elasticsearch output {:class=\>"LogStash::Outputs::ElasticSearch", :hosts=\>["[http://localhost:9200](http://localhost:9200)"]}  
[2018-02-23T09:49:44,357][INFO][logstash.pipeline] Starting pipeline {:pipeline\_id=\>"main", "pipeline.workers"=\>4, "pipeline.batch.size"=\>125, "pipeline.batch.delay"=\>5, "pipeline.max\_inflight"=\>500, :thread=\>"#\<Thread:0x3cee0587 run\>"}  
[2018-02-23T09:49:45,300][INFO][logstash.pipeline] Pipeline started {"pipeline.id"=\>"main"}  
[2018-02-23T09:49:45,856][INFO][logstash.agent] Pipelines running {:count=\>1, :pipelines=\>["main"]}  
[2018-02-23T09:49:48,503][WARN][logstash.outputs.elasticsearch] Could not index event to Elasticsearch. {:status=\>400, :action=\>["index", {:\_id=\>nil, :\_index=\>"chicago\_crime", :\_type=\>"doc", :\_routing=\>nil}, #LogStash::Event:0x7c9e0fce], :response=\>{"index"=\>{"\_index"=\>"chicago\_crime", "\_type"=\>"doc", "\_id"=\>"coMkw2EBzT\_mw5xoPw7t", "status"=\>400, "error"=\>{"type"=\>"illegal\_argument\_exception", "reason"=\>"[location] is defined as an object in mapping [doc] but this name is already used for a field in other types"}}}}  
2018-02-23T14:49:46.793Z [EdgeNode.asotc.com](http://EdgeNode.asotc.com) id,case number,date,block,iucr,primary type,description,location description,arrest,domestic,district,ward,community area,year,latitude,longitude  
[2018-02-23T09:49:49,097][WARN][logstash.outputs.elasticsearch] Could not index event to Elasticsearch. {:status=\>400, :action=\>["index", {:\_id=\>nil, :\_index=\>"chicago\_crime", :\_type=\>"doc", :\_routing=\>nil}, #LogStash::Event:0x2baeadd7], :response=\>{"index"=\>{"\_index"=\>"chicago\_crime", "\_type"=\>"doc", "\_id"=\>"c4Mkw2EBzT\_mw5xoPw70", "status"=\>400, "error"=\>{"type"=\>"illegal\_argument\_exception", "reason"=\>"[location] is defined as an object in mapping [doc] but this name is already used for a field in other types"}}}}

---

<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:** [March 23, 2018, 2:53pm UTC](https://discuss.elastic.co/t/help-with-geo-point-longitude-and-latitude/117333/8 "2018-03-23T14:53:43Z")

</div>

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