# Map geo\_point field in Elasticsearch

**URL:** https://discuss.elastic.co/t/map-geo-point-field-in-elasticsearch/135218
**Category:** Logstash
**Created:** [June 9, 2018, 9:33am UTC](https://discuss.elastic.co/t/map-geo-point-field-in-elasticsearch/135218 "2018-06-09T09:33:22Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![espogian](https://avatars.discourse-cdn.com/v4/letter/e/4491bb/32.png) [@espogian](https://discuss.elastic.co/u/espogian)
#### Post date: [June 9, 2018, 9:33am UTC](https://discuss.elastic.co/t/map-geo-point-field-in-elasticsearch/135218/1 "2018-06-09T09:33:22Z")

</div>

Hi there.

I have defined a field named location which is an array with longitude and latitude.  
I noticed that Logstash is indexing this field as a float and is not being recognized natively as geographical point in Elasticsearch.  
I have tried to change the mapping as follows:

```
PUT _template/logstash
...
    "mappings": {
...
    "properties": {
...
		  "location": {
			"type": "geo_point"
		  },

```

The thing is working but I'm receiving a warning about the fact that index mapping is deprecated.  
Which is the best practice now?  
Also, it would be nice to have the field recognized as geographical point right at ingest time.

Thank you

---

<div class="post-metadata">

### Author: ![espogian](https://avatars.discourse-cdn.com/v4/letter/e/4491bb/32.png) [@espogian](https://discuss.elastic.co/u/espogian)
#### Post date: [June 9, 2018, 11:05am UTC](https://discuss.elastic.co/t/map-geo-point-field-in-elasticsearch/135218/2 "2018-06-09T11:05:58Z")

</div>

I think I found a possible solution, mapping like this:

```
PUT _template/logstash
{
	"index_patterns": ["logstash-*"],
	"mappings": {
		"doc": {
			"properties": {
				"location": {
					"type": "geo_point"
				}
			}
		}
	}
}
```

---

<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: [June 9, 2018, 12:59pm UTC](https://discuss.elastic.co/t/map-geo-point-field-in-elasticsearch/135218/3 "2018-06-09T12:59:31Z")

</div>

This is the right approach, but that overwrites the template loaded by logstash. You should probably call the template something other than logstash.

---

<div class="post-metadata">

### Author: ![espogian](https://avatars.discourse-cdn.com/v4/letter/e/4491bb/32.png) [@espogian](https://discuss.elastic.co/u/espogian)
#### Post date: [June 9, 2018, 1:41pm UTC](https://discuss.elastic.co/t/map-geo-point-field-in-elasticsearch/135218/4 "2018-06-09T13:41:24Z")

</div>

Do you mean changing index\_patterns?

---

<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: [June 9, 2018, 2:43pm UTC](https://discuss.elastic.co/t/map-geo-point-field-in-elasticsearch/135218/5 "2018-06-09T14:43:37Z")

</div>

No, I mean change the name of the template itself.

```
PUT _template/logstash-location
```

---

<div class="post-metadata">

### Author: ![espogian](https://avatars.discourse-cdn.com/v4/letter/e/4491bb/32.png) [@espogian](https://discuss.elastic.co/u/espogian)
#### Post date: [June 10, 2018, 7:49am UTC](https://discuss.elastic.co/t/map-geo-point-field-in-elasticsearch/135218/6 "2018-06-10T07:49:52Z")

</div>

Thank you. What happens when I have two templates (logstash and logstash-location) which point to the same index-patterns?

---

<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: [June 10, 2018, 1:04pm UTC](https://discuss.elastic.co/t/map-geo-point-field-in-elasticsearch/135218/7 "2018-06-10T13:04:22Z")

</div>

The [documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html) covers this. If multiple templates match they are merged. You can control precedence with the order parameter.

---

<div class="post-metadata">

### Author: ![espogian](https://avatars.discourse-cdn.com/v4/letter/e/4491bb/32.png) [@espogian](https://discuss.elastic.co/u/espogian)
#### Post date: [June 10, 2018, 2:01pm UTC](https://discuss.elastic.co/t/map-geo-point-field-in-elasticsearch/135218/8 "2018-06-10T14:01:07Z")

</div>

Thank you, that was very useful!

---

<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: [July 8, 2018, 2:01pm UTC](https://discuss.elastic.co/t/map-geo-point-field-in-elasticsearch/135218/9 "2018-07-08T14:01:08Z")

</div>

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