# Error when mapping coordinates

**URL:** <https://discuss.elastic.co/t/error-when-mapping-coordinates/136586>\
**Category:** Kibana\
**Created:** [June 20, 2018, 12:33am UTC](https://discuss.elastic.co/t/error-when-mapping-coordinates/136586 "2018-06-20T00:33:06Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![aeissa](https://avatars.discourse-cdn.com/v4/letter/a/f0a364/32.png) [@aeissa](https://discuss.elastic.co/u/aeissa)\
**Post date:** [June 20, 2018, 12:33am UTC](https://discuss.elastic.co/t/error-when-mapping-coordinates/136586/1 "2018-06-20T00:33:06Z")

</div>

Been stuck on this for a while.

In Python, I'm using the Tweepy and Elasticsearch libraries to stream tweets to an Elasticsearch index. In my Python script, my index is created as:

```
settings = {
'settings': {
	'number_of_shards': 1,
	'number_of_replicas': 0
},
'mappings': {
	'tweet': {
		'_all': {'enabled': 'false'},
		'_timestamp': {'enabled': 'true'},
		'properties': {
			'id': {'type': 'long'},
			'text': {'type': 'text'},
			'name': {'type': 'text'},
			'screen_name': {'type': 'text'},
			'coordinates': {'type': 'geo_point'}
		}
	}
}

}

```

A separate script, _stream.py_, collects tweets and indexes certain information. If a place in the tweet is available, I calculate the center from the provided bounding box. Sample (from printing to console) coordinates include:

```
place found and calculated
[42.43, -82.9]
place found and calculated
[33.55, -112.12]
place found and calculated
[40.03, -75.37]
place found and calculated
[19.43, -99.15]  

```

The script rounds the coordinates to two decimal places. Whenever I attempt to visualize on a map in Kibana, I get the error "Visualize: Expected geo\_point type on field [coordinates], but got [float]."

As far as I can tell, though, this array of coordinates is in the exact format a _geo\_point_ should be ([https://www.elastic.co/guide/en/elasticsearch/reference/current/geo-point.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/geo-point.html)).

Any ideas? I know plotting location data from Twitter is fairly common for ELK, but it seems like syntax is always changing.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [June 20, 2018, 1:13am UTC](https://discuss.elastic.co/t/error-when-mapping-coordinates/136586/2 "2018-06-20T01:13:36Z")

</div>

What does the `_mapping` look like for the index?

---

<div class="post-metadata">

**Author:** ![aeissa](https://avatars.discourse-cdn.com/v4/letter/a/f0a364/32.png) [@aeissa](https://discuss.elastic.co/u/aeissa)\
**Post date:** [June 20, 2018, 1:29am UTC](https://discuss.elastic.co/t/error-when-mapping-coordinates/136586/3 "2018-06-20T01:29:19Z")

</div>

Is there a mapping other than what I've highlighted above? Thanks replying so quickly!

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [June 20, 2018, 7:14am UTC](https://discuss.elastic.co/t/error-when-mapping-coordinates/136586/4 "2018-06-20T07:14:49Z")

</div>

Well there is the one you apply, but it doesn't look like that has worked.  
So what is the actual mapping in Elasticsearch for the index.

---

<div class="post-metadata">

**Author:** ![aeissa](https://avatars.discourse-cdn.com/v4/letter/a/f0a364/32.png) [@aeissa](https://discuss.elastic.co/u/aeissa)\
**Post date:** [June 20, 2018, 3:38pm UTC](https://discuss.elastic.co/t/error-when-mapping-coordinates/136586/5 "2018-06-20T15:38:20Z")

</div>

Ah, ok - I didn't know that what I applied via ES module in python may not have been what was actually there. I consulted the docs for [Get Mapping](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-mapping.html) and received the following from **[http://localhost:9200/python-twitter/\_mapping](http://localhost:9200/python-twitter/_mapping)**:

```
{
"python-twitter": {
	"mappings": {
		"tweet": {
			"properties": {
				"coordinates": {
					"type": "float"
				},
				"id": {
					"type": "long"
				},
				"name": {
					"type": "text",
					"fields": {
						"keyword": {
							"type": "keyword",
							"ignore_above": 256
						}
					}
				},
				"screen_name": {
					"type": "text",
					"fields": {
						"keyword": {
							"type": "keyword",
							"ignore_above": 256
						}
					}
				},
				"text": {
					"type": "text",
					"fields": {
						"keyword": {
							"type": "keyword",
							"ignore_above": 256
						}
					}
				},
				"timestamp": {
					"type": "date"
				}
			}
		}
	}
}
}
```

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [June 20, 2018, 9:10pm UTC](https://discuss.elastic.co/t/error-when-mapping-coordinates/136586/6 "2018-06-20T21:10:17Z")

</div>

It's not a python thing, it's a "let's just be sure" 🙂

You can see there ;

> [@aeissa](#):
>
> "coordinates": { "type": "float" },

So your settings aren't being applied properly for some reason.

---

<div class="post-metadata">

**Author:** ![aeissa](https://avatars.discourse-cdn.com/v4/letter/a/f0a364/32.png) [@aeissa](https://discuss.elastic.co/u/aeissa)\
**Post date:** [June 21, 2018, 12:43am UTC](https://discuss.elastic.co/t/error-when-mapping-coordinates/136586/7 "2018-06-21T00:43:06Z")

</div>

Hm, interesting. I wonder if the method of creating index and its mapping I've chosen isn't the best? For reference, here's the script. It deletes the existing index and creates a new one every time I run it:

```
from elasticsearch import Elasticsearch

es = Elasticsearch()

if es.indices.exists('python-twitter'):
    es.indices.delete(index='python-twitter')

settings = {
'settings': {
	'number_of_shards': 1,
	'number_of_replicas': 0
},
'mappings': {
	'tweet': {
		'_all': {'enabled': 'false'},
		'_timestamp': {'enabled': 'true'},
		'properties': {
			'id': {'type': 'long'},
			'text': {'type': 'text'},
			'name': {'type': 'text'},
			'screen_name': {'type': 'text'},
			'coordinates': {'type': 'geo_point'}
		}
	}
}

es.indices.create(index='python-twitter', ignore=400, body=settings)
```

---

<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 19, 2018, 12:43am UTC](https://discuss.elastic.co/t/error-when-mapping-coordinates/136586/8 "2018-07-19T00:43:14Z")

</div>

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