# Index twitter data with coordinates geo\_point parse exception

**URL:** <https://discuss.elastic.co/t/index-twitter-data-with-coordinates-geo-point-parse-exception/109259>\
**Category:** Elasticsearch\
**Created:** [November 27, 2017, 5:26pm UTC](https://discuss.elastic.co/t/index-twitter-data-with-coordinates-geo-point-parse-exception/109259 "2017-11-27T17:26:57Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bruno\_Lavoie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bruno_lavoie/32/8408_2.png) [@Bruno\_Lavoie](https://discuss.elastic.co/u/Bruno_Lavoie)\
**Post date:** [November 27, 2017, 5:26pm UTC](https://discuss.elastic.co/t/index-twitter-data-with-coordinates-geo-point-parse-exception/109259/1 "2017-11-27T17:26:57Z")

</div>

Hello,

I'm trying to index some twitter data without success because of the coordinates field that I want to use as geo\_point.

Here is my template:

> <https://gist.github.com/blavoie/b98c9fa3d279aab1ebc7fe8430c5dbb4>

Here is a document:

> <https://gist.github.com/blavoie/168cc505954062c0920904bf44bb2c99>

When I run steps to delete index, replace template and insert my document I'm getting an error:

```
{"error":{"root_cause":[{"type":"parse_exception","reason":"geo_point expected"}],"type":"mapper_parsing_exception","reason":"failed to parse","caused_by":{"type":"parse_exception","reason":"geo_point expected"}},"status":400}

```

Steps:

```
HOSTNAME=localhost
curl -XDELETE http://$HOSTNAME:9200/ul-twitter-test
curl -XPUT http://$HOSTNAME:9200/_template/ul-twitter -d @templates/ul-twitter.basic.json
curl -XPUT http://$HOSTNAME:9200/ul-twitter-test/tweets/1 -d @samples/tweet-with-geopoint.json

```

Currently running with version 5.6.4.

Any clues?

Thanks  
Bruno

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [November 28, 2017, 7:53am UTC](https://discuss.elastic.co/t/index-twitter-data-with-coordinates-geo-point-parse-exception/109259/2 "2017-11-28T07:53:35Z")

</div>

Hey,

you are actually not indexing a `geo_point` (that consists only of a lon and lat pair), but a `geo_shape`, which in your example incidentally turns out to be a point, but could also be a line or a polygon.

In order to fix this, you could just use this in your tweet

```auto
coordinates: { lat: 11, lon: 12 }

```

and then everything should work

--Alex

---

<div class="post-metadata">

**Author:** ![Bruno\_Lavoie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bruno_lavoie/32/8408_2.png) [@Bruno\_Lavoie](https://discuss.elastic.co/u/Bruno_Lavoie)\
**Post date:** [November 28, 2017, 2:37pm UTC](https://discuss.elastic.co/t/index-twitter-data-with-coordinates-geo-point-parse-exception/109259/3 "2017-11-28T14:37:05Z")

</div>

Hello @spinscale,

Thanks for your response, but as per documentation geo\_point type can be passed as an array:  
[https://www.elastic.co/guide/en/elasticsearch/reference/5.6/geo-point.html](https://www.elastic.co/guide/en/elasticsearch/reference/5.6/geo-point.html)

Snippet:

```
PUT my_index/my_type/4
{
  "text": "Geo-point as an array",
  "location": [-71.34, 41.12] 
}

```

What am I missing?

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [November 28, 2017, 2:50pm UTC](https://discuss.elastic.co/t/index-twitter-data-with-coordinates-geo-point-parse-exception/109259/4 "2017-11-28T14:50:34Z")

</div>

nothing. Just because it works, does not mean it is intuitive to me 🙂

The person coming after you has to know which is the latitude and the longitude. And this person also needs to know, if you write a geo point as a string like`41.12, -71.34`, you need to reverse it to make it work. Because of that I am just always preferring to mark, which field represents what by naming it appropriately. Internally everyone of those three representations gets stored the same for, so it does not make a difference when searching.

personal preference, you may ignore 🙂

---

<div class="post-metadata">

**Author:** ![Bruno\_Lavoie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bruno_lavoie/32/8408_2.png) [@Bruno\_Lavoie](https://discuss.elastic.co/u/Bruno_Lavoie)\
**Post date:** [November 28, 2017, 4:33pm UTC](https://discuss.elastic.co/t/index-twitter-data-with-coordinates-geo-point-parse-exception/109259/5 "2017-11-28T16:33:23Z")

</div>

Yes, makes sense about personal preferences, but I meant that the tweet payload comes with this:

```
  "coordinates" : {
    "type" : "Point",
    "coordinates" : [-84.51194444, 37.47361111]
  },

```

and my mapping template for coordinates.coordinates type is geo\_point and it doesn't work... as this representation is normally correctly handled by elasticsearch (as per doc).

.... I'm really puzzled

Thanks

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [November 28, 2017, 7:15pm UTC](https://discuss.elastic.co/t/index-twitter-data-with-coordinates-geo-point-parse-exception/109259/6 "2017-11-28T19:15:16Z")

</div>

no, this representation only works for a geo shape, a point needs to be modelled like this

```auto
coordinates: [-84.51194444, 37.47361111]

```

```auto
coordinates: "37.47361111, -84.51194444, "

```

or

```auto
coordinates: { lon: 37.47361111, lat: -84.51194444, }

```

the structure that you got resembles a geo shape because it contains the type and coordinates field **inside** of the coordinates field.

hope this makes sense

---

<div class="post-metadata">

**Author:** ![Bruno\_Lavoie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bruno_lavoie/32/8408_2.png) [@Bruno\_Lavoie](https://discuss.elastic.co/u/Bruno_Lavoie)\
**Post date:** [November 28, 2017, 7:59pm UTC](https://discuss.elastic.co/t/index-twitter-data-with-coordinates-geo-point-parse-exception/109259/7 "2017-11-28T19:59:14Z")

</div>

Sorry, not clear yet... 🤔

The field coordinates.coordinates is an array, and by the template this field is defined to be a geo\_point, and per doc an array is a valid representation of geo\_point...

is it because it must not be in an object? on the root?

---

<div class="post-metadata">

**Author:** ![Jim\_Weng](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jim_weng/32/24793_2.png) [@Jim\_Weng](https://discuss.elastic.co/u/Jim_Weng)\
**Post date:** [November 28, 2017, 8:03pm UTC](https://discuss.elastic.co/t/index-twitter-data-with-coordinates-geo-point-parse-exception/109259/8 "2017-11-28T20:03:06Z")

</div>

I had same problem liked yours.  
And I fixed the problem by the script below.  
Hope that works for you too.

> <https://github.com/jimweng/elastic-search/blob/master/template.json>

---

<div class="post-metadata">

**Author:** ![Bruno\_Lavoie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bruno_lavoie/32/8408_2.png) [@Bruno\_Lavoie](https://discuss.elastic.co/u/Bruno_Lavoie)\
**Post date:** [November 29, 2017, 2:07pm UTC](https://discuss.elastic.co/t/index-twitter-data-with-coordinates-geo-point-parse-exception/109259/9 "2017-11-29T14:07:58Z")

</div>

Thanks @Jim_Weng you are right!

Still don't get how is Elasticsearch is doing things between your template and mine: very simple details! All this in a curly brace party. 🙂

You saved me hours.

---

<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:** [December 27, 2017, 2:08pm UTC](https://discuss.elastic.co/t/index-twitter-data-with-coordinates-geo-point-parse-exception/109259/10 "2017-12-27T14:08:14Z")

</div>

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