Changing lat/lon from float to geo_point

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
}

1 Like

Please format your code using </> icon as explained in this guide. 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 for more information.

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.

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:

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

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.

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

That's not how you define a geo_point field.

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

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?

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

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" ]
                }
2 Likes

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