# Concatenate 2 values to make a geo\_point field

**URL:** https://discuss.elastic.co/t/concatenate-2-values-to-make-a-geo-point-field/194175
**Category:** Elasticsearch
**Created:** [August 7, 2019, 8:16am UTC](https://discuss.elastic.co/t/concatenate-2-values-to-make-a-geo-point-field/194175 "2019-08-07T08:16:19Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Ragnar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ragnar/32/7610_2.png) [@Ragnar](https://discuss.elastic.co/u/Ragnar)
#### Post date: [August 7, 2019, 8:16am UTC](https://discuss.elastic.co/t/concatenate-2-values-to-make-a-geo-point-field/194175/1 "2019-08-07T08:16:19Z")

</div>

I have an index where from an ip field from the data source I have added the filter `geoip` to logstash that get the data. I got in my index a brand new bunch of field about latitude, longitude, city... but it's not usable as it is to pinpoint on a map since the long/lat are of type string or number.

I added to the mapping of this index a new field of type `geo_point` and I would like now to fill it with the concatenation of "lon"+","+"lat" like the seconde exemple [here](https://www.elastic.co/guide/en/elasticsearch/reference/5.5/geo-point.html#geo-point).

Can I do that easily ?

---

<div class="post-metadata">

### Author: ![ftr](https://avatars.discourse-cdn.com/v4/letter/f/3bc359/32.png) [@ftr](https://discuss.elastic.co/u/ftr)
#### Post date: [August 7, 2019, 6:42pm UTC](https://discuss.elastic.co/t/concatenate-2-values-to-make-a-geo-point-field/194175/2 "2019-08-07T18:42:14Z")

</div>

Don't know if it counts as "easy", but you can iterate a script over the documents in your index. Assume that you have the index "locations" with the latitude in the "lat" field and the longitude in the "lon" field and the file "script" contains the following line:

`{"script" : {"source" : "ctx._source[\"loc\"] = [ctx._source[\"lat\"],ctx._source[\"lon\"]]", "lang" : "painless" } }`

Then the linux command

`curl -XPOST 'http://localhost:9200/locations/_doc/1/_update' -H 'content-type:application/json' -d@script`

will update the document with \_id = 1 so that the (geo\_point) field "loc" contains the location.

NB: The above curl line assumes that you are using ES 6.x (or earlier). For ES 7.x, drop the "\_doc" part of the path for curl, since elasticsearch finally dropped the idea of 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: [September 4, 2019, 6:42pm UTC](https://discuss.elastic.co/t/concatenate-2-values-to-make-a-geo-point-field/194175/3 "2019-09-04T18:42:18Z")

</div>

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