# Changing lat/lon from float to geo\_point

**URL:** <https://discuss.elastic.co/t/changing-lat-lon-from-float-to-geo-point/116067>\
**Category:** Elasticsearch\
**Created:** [January 18, 2018, 1:43pm UTC](https://discuss.elastic.co/t/changing-lat-lon-from-float-to-geo-point/116067 "2018-01-18T13:43:50Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![jgwentworth](https://avatars.discourse-cdn.com/v4/letter/j/97f17d/32.png) [@jgwentworth](https://discuss.elastic.co/u/jgwentworth)\
**Post date:** [January 18, 2018, 1:43pm UTC](https://discuss.elastic.co/t/changing-lat-lon-from-float-to-geo-point/116067/1 "2018-01-18T13:43:51Z")

</div>

When running GET myindex/\_mapping, I'm trying to use that same output to replace the mapping of lat/lon from datatype float to geo\_point with a put request. However, I'm getting the error:

{  
"error": {  
"root\_cause": [  
{  
"type": "action\_request\_validation\_exception",  
"reason": "Validation Failed: 1: mapping type is missing;"  
}  
],  
"type": "action\_request\_validation\_exception",  
"reason": "Validation Failed: 1: mapping type is missing;"  
},  
"status": 400  
}

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [January 18, 2018, 1:56pm UTC](https://discuss.elastic.co/t/changing-lat-lon-from-float-to-geo-point/116067/2 "2018-01-18T13:56:38Z")

</div>

Please format your code using `</>` icon as explained in [this guide](https://discuss.elastic.co/t/about-the-elasticsearch-category/21). It will make your post more readable.

Or use markdown style like:

````
```
CODE
```

````

It depends on how you send it I guess. Read [https://www.elastic.co/guide/en/elasticsearch/reference/6.1/indices-put-mapping.html](https://www.elastic.co/guide/en/elasticsearch/reference/6.1/indices-put-mapping.html) for more information.

---

<div class="post-metadata">

**Author:** ![jgwentworth](https://avatars.discourse-cdn.com/v4/letter/j/97f17d/32.png) [@jgwentworth](https://discuss.elastic.co/u/jgwentworth)\
**Post date:** [January 18, 2018, 2:46pm UTC](https://discuss.elastic.co/t/changing-lat-lon-from-float-to-geo-point/116067/3 "2018-01-18T14:46:22Z")

</div>

Hi David,

I have tried using the following:

```
PUT my_index/my_type/1
{
  "text": "Geo-point as an object",
  "location": { 
    "lat": 41.12,
    "lon": -71.34
  }
}

```

I received the following error:

```
"type": "mapper_parsing_exception",
        "reason": "Root mapping definition has unsupported parameters: [text : Geo-point as an object] [location : {lat=41.12, lon=-71.34}]"

```

Also is there any reason why you can't specifically state the field type geo\_point in logstash?

Thanks, for the quick reply.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [January 18, 2018, 3:09pm UTC](https://discuss.elastic.co/t/changing-lat-lon-from-float-to-geo-point/116067/4 "2018-01-18T15:09:07Z")

</div>

Sorry but your pasted code does not make sense.

> PUT my\_index/my\_type/1

This is meant to index a document.

I don't see how you can get such an error message with that command.  
Could you reproduce from scratch? Like:

```auto
DELETE test
PUT test
PUT test/doc/1
{
  "text": "Geo-point as an object",
  "location": { 
    "lat": 41.12,
    "lon": -71.34
  }
}

```

---

<div class="post-metadata">

**Author:** ![jgwentworth](https://avatars.discourse-cdn.com/v4/letter/j/97f17d/32.png) [@jgwentworth](https://discuss.elastic.co/u/jgwentworth)\
**Post date:** [January 18, 2018, 4:35pm UTC](https://discuss.elastic.co/t/changing-lat-lon-from-float-to-geo-point/116067/5 "2018-01-18T16:35:16Z")

</div>

Running your test code did not reproduce the same error.  
I ran the following code as well which should work?

```
PUT case12
{
  "_mapping": {
    "geoip": {
      "properties": {
        "location": {
                "properties": {
                  "lat": {
                    "type": "geo_point"
                  },
                  "lon": {
                    "type": "geo_point"
                  }
                }
			}
      }
    }
  }
}

```

but instead produced the following error:

```
{
  "error": {
    "root_cause": [
      {
        "type": "illegal_argument_exception",
        "reason": "unknown setting [index._mapping.geoip.properties.location.properties.lat.type] please check that any required plugins are installed, or check the breaking changes documentation for removed settings"
      }
    ],
    "type": "illegal_argument_exception",
    "reason": "unknown setting [index._mapping.geoip.properties.location.properties.lat.type] please check that any required plugins are installed, or check the breaking changes documentation for removed settings"
  },
  "status": 400
}

```

Thanks again for your time.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [January 18, 2018, 5:05pm UTC](https://discuss.elastic.co/t/changing-lat-lon-from-float-to-geo-point/116067/6 "2018-01-18T17:05:57Z")

</div>

That's not how you create an index with mappings.

See [https://www.elastic.co/guide/en/elasticsearch/reference/6.1/indices-create-index.html#mappings](https://www.elastic.co/guide/en/elasticsearch/reference/6.1/indices-create-index.html#mappings)

That's not how you define a geo\_point field.

See [https://www.elastic.co/guide/en/elasticsearch/reference/6.1/geo-point.html](https://www.elastic.co/guide/en/elasticsearch/reference/6.1/geo-point.html)

---

<div class="post-metadata">

**Author:** ![jgwentworth](https://avatars.discourse-cdn.com/v4/letter/j/97f17d/32.png) [@jgwentworth](https://discuss.elastic.co/u/jgwentworth)\
**Post date:** [January 18, 2018, 5:52pm UTC](https://discuss.elastic.co/t/changing-lat-lon-from-float-to-geo-point/116067/7 "2018-01-18T17:52:38Z")

</div>

Hi David,

Thanks for your help so far.

Using this code

```
PUT case12/_mapping/doc?format=yaml
{
      "properties": {
        "location": {
            "properties": {
                  "lat": {
                    "type": "geo_point"
                  },
                  "lon": {
                    "type": "geo_point"
                  }
                }
        }
      }
    }

```

I was able to successfully add these two fields as geo\_point data types according to Management -\> index Patterns -\> refresh field types. However, when I go to visualize it states that these fields are still numbers.

Any ideas?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [January 18, 2018, 6:10pm UTC](https://discuss.elastic.co/t/changing-lat-lon-from-float-to-geo-point/116067/8 "2018-01-18T18:10:48Z")

</div>

This is still wrong. Read carefully the link about geo points.  
Location is the geo point field. Not lat, not lon.

---

<div class="post-metadata">

**Author:** ![jgwentworth](https://avatars.discourse-cdn.com/v4/letter/j/97f17d/32.png) [@jgwentworth](https://discuss.elastic.co/u/jgwentworth)\
**Post date:** [January 19, 2018, 2:01pm UTC](https://discuss.elastic.co/t/changing-lat-lon-from-float-to-geo-point/116067/9 "2018-01-19T14:01:23Z")

</div>

got it working, thanks David.

for those wondering on the fix:

before indexing any data create this index mapping

```
PUT case12
{
  "mappings": {
    "doc": {
      "properties": {
        "geoip.coordinates": {
          "type": "geo_point"
        }
      }
    }
  }
}

```

in logstash I have this config under filter:

```
 geoip {
                        source => "Source Network Address"
                        target => "geoip"
                        add_tag => ["geoip"]
                        add_field => ["[geoip][coordinates]", "%{[geoip][longitude]}"]
                        add_field => ["[geoip][coordinates]", "%{[geoip][latitude]}" ]

                }
 mutate {
                        convert => ["[geoip][coordinates]", "float" ]
                }
```

---

<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:** [February 16, 2018, 2:01pm UTC](https://discuss.elastic.co/t/changing-lat-lon-from-float-to-geo-point/116067/10 "2018-02-16T14:01:28Z")

</div>

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