[ES7] Can't POST a geo_point

I'm working with this setup

"version": {
    "number": "7.2.0",
    "build_flavor": "oss",
    "build_type": "tar",
    "build_hash": "508d38a",
    "build_date": "2019-06-20T15:54:18.811730Z",
    "build_snapshot": false,
    "lucene_version": "8.0.0",
    "minimum_wire_compatibility_version": "6.8.0",
    "minimum_index_compatibility_version": "6.0.0-beta1"
  },

I'm doing exactly as explained here.

PUT my_index
{
  "mappings": {
    "properties": {
      "location": {
        "type": "geo_point"
      }
    }
  }
}

I can confirm that the index is correctly created:

{
    "my_index": {
        "aliases": {},
        "mappings": {
            "properties": {
                "location": {
                    "type": "geo_point"
                }
            }
        },
        "settings": {
            "index": {
                "number_of_shards": "1",
                "auto_expand_replicas": null,
                "provided_name": "my_index",
                "creation_date": "1583495525728",
                "priority": "0",
                "number_of_replicas": "1",
                "uuid": "KEtK4VDxSXsfseD5C0A1Q",
                "version": {
                    "created": "7021099"
                }
            }
        }
    }
}

But when I perform a POST query to insert some coordinates:

POST /my_index/my_index
{
  "text": "Geo-point as an object",
  "location": { 
    "lat": 41.12,
    "lon": -71.34
  }
}

This is the answer:

{
    "error": {
        "root_cause": [
            {
                "type": "illegal_argument_exception",
                "reason": "mapper [location] of different type, current_type [geo_point], merged_type [ObjectMapper]"
            }
        ],
        "type": "illegal_argument_exception",
        "reason": "mapper [location] of different type, current_type [geo_point], merged_type [ObjectMapper]"
    },
    "status": 400
}

I don't understand what am I doing wrong. I also tried the other POST geo_point syntaxes with no luck.

This works very well:

DELETE my_index
PUT my_index
{
  "mappings": {
    "properties": {
      "location": {
        "type": "geo_point"
      }
    }
  }
}
POST /my_index/_doc
{
  "text": "Geo-point as an object",
  "location": { 
    "lat": 41.12,
    "lon": -71.34
  }
}

@dadoonet Seems like I found the problem, if you can please help me to confirm:

If I put some data in a custom type, let's say making a POST /my_index/my_type everything works fine as long as I don't use a geo_point. But if I want to use a geo_point the only way is to use the seemingly default _doc type.

This is aligned with the new mapping paradigm but maybe because, as I noticed, in my setup I have "minimum_index_compatibility_version": "6.0.0-beta1", the API still allowed me to have non default types.

Not sure I understood.
But the example I shared with you works, right?

If so, you can use it to solve your problem?

It works, it's taken from the example I linked, my question is why when I perform a POST like this

It doesn't work, which maybe is because ES7, doesn't allow to use types different from _doc.

Maybe. I'm not sure, I can't find explicit confirmation.

The default type under the hood in ES7 is indeed _doc. You must use that one.

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