# Geo\_point mapping python and Streamsets fails with Elasticsearch

**URL:** <https://discuss.elastic.co/t/geo-point-mapping-python-and-streamsets-fails-with-elasticsearch/228486>\
**Category:** Elasticsearch\
**Created:** [April 17, 2020, 9:57am UTC](https://discuss.elastic.co/t/geo-point-mapping-python-and-streamsets-fails-with-elasticsearch/228486 "2020-04-17T09:57:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![drules](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/drules/32/66391_2.png) [@drules](https://discuss.elastic.co/u/drules)\
**Post date:** [April 17, 2020, 9:57am UTC](https://discuss.elastic.co/t/geo-point-mapping-python-and-streamsets-fails-with-elasticsearch/228486/1 "2020-04-17T09:57:06Z")

</div>

I have this mapping in elasticsearch

```
"mappings": {
      "properties": {
            "fromCoordinates": {"type": "geo_point"},
            "toCoordinates": {"type": "geo_point"},
            "seenCoordinates": {"type": "geo_point"},
        }
    }

```

With the kibana's console, there is no problem with all possible combinations of geo\_ip [fields supported by elasticsearch](https://www.elastic.co/guide/en/elasticsearch/reference/current/geo-point.html), i.e:

(lat, lon)

```auto
PUT /anindex/_doc/1
{
   "fromCoordinates": {
     "lat": 36.857200622558594    
     "lon": 117.21600341796875,

  },
  "toCoordinates": {
    "lat": 22.639299392700195    
    "lon": 113.81099700927734,

  },
  "seenCoordinates": {
     "lat": 36.91663    
     "lon": 117.216,
   }
}

```

(lon,lat)

```auto
PUT /anindex/_doc/2
{
 "fromCoordinates": [36.857200622558594, 117.21600341796875], 
 "toCoordinates": [22.639299392700195, 113.81099700927734], 
 "seenCoordinates": [36.91663, 117.216] 
}

```

But a I tried inserting, into elasticsearch, the data through python, and I always have this error:

`RequestError(400, 'illegal_argument_exception', 'mapper [fromCoordinates] of different type, current_type [geo_point], merged_type [ObjectMapper]')`

In python, I construct the json from a dictionary, and this is the result when I printed:

```auto
fromCoordinates = {}
fromCoordinates['lat'] = fromLat  
fromCoordinates['lon'] = fromLon 

dataDictionary.update({'fromCoordinates': fromCoordinates , 'toCoordinates': toCoordinates, 'seenCoordinates': seenCoordinates})

```

`print(json.dumps(dataDictionary).encode('utf-8'))`

```auto
{"fromCoordinates": {"lat": 43.9962005615, "lon": 125.684997559}, 
"toCoordinates": {"lat": 40.080101013183594, "lon": 116.58499908447266}, 
"seenCoordinates": {"lat": 33.62672, "lon": 109.37243}}

```

and load with this

```auto
data = json.dumps(dataDictionary).encode('utf-8')
es.create(index='anindex', doc_type='document', id=0, body=data)

```

The array version has the same problems:

`fromCoordinates = [fromLon, fromLat]`

This is the json created and printed in python:

```auto
{"fromCoordinates": [113.81099700927734, 22.639299392700195], 
  "toCoordinates": [106.8010025024414, 26.53849983215332], 
   "seenCoordinates": [107.46743, 26.34169]}

```

In this case I have this response

`RequestError: RequestError(400, 'mapper_parsing_exception', 'geo_point expected')`

The same error occurs if I try with StreamSets to elasticsearch, having the both types of json shown before:

`mapper [fromCoordinates] of different type, current_type [geo_point], merged_type [ObjectMapper]`

This is the mapping loaded in elastic:

```auto
GET /anindex/_mapping
{
  "anindex" : {
    "mappings" : {
      "properties" : {
        "fromCoordinates" : {
          "type" : "geo_point"
        },
        "toCoordinates" : {
          "type" : "geo_point"
        },        
        "seenCoordinates" : {
          "type" : "geo_point"
        }
       }
      }
    }
 }

```

Any ideas?

UPDATE:  
With curl, postman, kibana's console there is no problem with that. It clearly seems that the JSON nested fields are treated as an object and not "pure" json (plain) when I send them from python or from StreamsSets. I also tested with python and StreamSets without nested fields, and everything is ok. I also tried, without creating the mapping first and leaving elastic to guess and create by itself, and elastic mapped the coordinates as numbers or strings.  
I also tried building the json "by hand" and send it, and get the same error.

---

<div class="post-metadata">

**Author:** ![drules](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/drules/32/66391_2.png) [@drules](https://discuss.elastic.co/u/drules)\
**Post date:** [April 17, 2020, 2:06pm UTC](https://discuss.elastic.co/t/geo-point-mapping-python-and-streamsets-fails-with-elasticsearch/228486/2 "2020-04-17T14:06:52Z")

</div>

**SOLUTION:**

After the example given in [stackoverflow](https://stackoverflow.com/questions/61268424/geo-point-mapping-python-and-streamsets-fails-with-elasticsearch) I realized that the doc\_type parameter in  
'es.create(index='anindex', doc\_type='document', id=0, body=data)'  
is causing the error, I removed it, and it worked..... But I still wondering why in StreamSets has the same error... but I`ll continue with python.

---

<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:** [May 15, 2020, 2:06pm UTC](https://discuss.elastic.co/t/geo-point-mapping-python-and-streamsets-fails-with-elasticsearch/228486/3 "2020-05-15T14:06:59Z")

</div>

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