# \[ES7\] Can't POST a geo\_point

**URL:** <https://discuss.elastic.co/t/es7-cant-post-a-geo-point/222453>\
**Category:** Elasticsearch\
**Created:** [March 6, 2020, 12:04pm UTC](https://discuss.elastic.co/t/es7-cant-post-a-geo-point/222453 "2020-03-06T12:04:14Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![donnadulcinea](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/donnadulcinea/32/39276_2.png) [@donnadulcinea](https://discuss.elastic.co/u/donnadulcinea)\
**Post date:** [March 6, 2020, 12:04pm UTC](https://discuss.elastic.co/t/es7-cant-post-a-geo-point/222453/1 "2020-03-06T12:04:14Z")

</div>

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](https://www.elastic.co/guide/en/elasticsearch/reference/current/geo-point.html).

```
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.

---

<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:** [March 6, 2020, 3:49pm UTC](https://discuss.elastic.co/t/es7-cant-post-a-geo-point/222453/2 "2020-03-06T15:49:00Z")

</div>

This works very well:

```auto
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
  }
}

```

---

<div class="post-metadata">

**Author:** ![donnadulcinea](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/donnadulcinea/32/39276_2.png) [@donnadulcinea](https://discuss.elastic.co/u/donnadulcinea)\
**Post date:** [March 6, 2020, 4:31pm UTC](https://discuss.elastic.co/t/es7-cant-post-a-geo-point/222453/3 "2020-03-06T16:31:06Z")

</div>

> [@donnadulcinea](#):
>
> { "mappings": { "properties": { "location": { "type": "geo\_point" } } } }

@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](https://www.elastic.co/guide/en/elasticsearch/reference/current/removal-of-types.html) 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.

---

<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:** [March 10, 2020, 8:32am UTC](https://discuss.elastic.co/t/es7-cant-post-a-geo-point/222453/4 "2020-03-10T08:32:54Z")

</div>

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

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

---

<div class="post-metadata">

**Author:** ![donnadulcinea](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/donnadulcinea/32/39276_2.png) [@donnadulcinea](https://discuss.elastic.co/u/donnadulcinea)\
**Post date:** [March 11, 2020, 10:51am UTC](https://discuss.elastic.co/t/es7-cant-post-a-geo-point/222453/5 "2020-03-11T10:51:50Z")

</div>

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

> [@donnadulcinea](#):
>
> POST /my\_index/my\_index

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.

---

<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:** [March 11, 2020, 11:04am UTC](https://discuss.elastic.co/t/es7-cant-post-a-geo-point/222453/6 "2020-03-11T11:04:28Z")

</div>

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

---

<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:** [April 8, 2020, 11:04am UTC](https://discuss.elastic.co/t/es7-cant-post-a-geo-point/222453/7 "2020-04-08T11:04:35Z")

</div>

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