# ElasticSearch POST \_doc and doc issue

**URL:** <https://discuss.elastic.co/t/elasticsearch-post-doc-and-doc-issue/309097>\
**Category:** Elasticsearch\
**Created:** [July 7, 2022, 10:16am UTC](https://discuss.elastic.co/t/elasticsearch-post-doc-and-doc-issue/309097 "2022-07-07T10:16:17Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Even\_Zhang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/even_zhang/32/108012_2.png) [@Even\_Zhang](https://discuss.elastic.co/u/Even_Zhang)\
**Post date:** [July 7, 2022, 10:16am UTC](https://discuss.elastic.co/t/elasticsearch-post-doc-and-doc-issue/309097/1 "2022-07-07T10:16:17Z")

</div>

Hi everyone,

I through curl to POST new index with doc like

```auto
curl -XPOST -H "Content-Type: application/json" 'http://localhost:9200/portstats/doc/' -d '{"bytesReceived":0,"bytesSent":0,"@timestamp":"2022-07-10T23:43:01.637Z"}'

```

But I will get this error.

```auto
{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"Rejecting mapping update to [portstats] as the final mapping would have more than 1 type: [_doc, doc]"}],"type":"illegal_argument_exception","reason":"Rejecting mapping update to [portstats] as the final mapping would have more than 1 type: [_doc, doc]"},"status":400}%

```

Even if I remove the index porstats

```auto
curl -XDELETE http://127.0.0.1:9200/portstats

```

It's useless, when I POST again I will get the same error message.  
I guess when I POST it will create type \_doc automatically, but I don't know why the type isn't "doc"

Does anyone knows? Thanks.

---

<div class="post-metadata">

**Author:** ![RabBit\_BR](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rabbit_br/32/82261_2.png) [@RabBit\_BR](https://discuss.elastic.co/u/RabBit_BR)\
**Post date:** [July 7, 2022, 12:52pm UTC](https://discuss.elastic.co/t/elasticsearch-post-doc-and-doc-issue/309097/2 "2022-07-07T12:52:51Z")

</div>

Hi @Even_Zhang .

What is version ES you are using?

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [July 7, 2022, 4:13pm UTC](https://discuss.elastic.co/t/elasticsearch-post-doc-and-doc-issue/309097/3 "2022-07-07T16:13:07Z")

</div>

Hi @Even_Zhang Welcome to the community

> [@Even\_Zhang](#):
>
> `'http://localhost:9200/portstats/doc/'`

If you are using Elasticsearch version 7.x+ that would be `_doc` not `doc`

`http://localhost:9200/portstats/_doc/`  
`................................^`

`_doc` Is the only non-deprecated `_type` allowed

See [this](https://www.elastic.co/guide/en/elasticsearch/reference/7.17/removal-of-types.html) ... For an explanation.

---

<div class="post-metadata">

**Author:** ![Even\_Zhang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/even_zhang/32/108012_2.png) [@Even\_Zhang](https://discuss.elastic.co/u/Even_Zhang)\
**Post date:** [July 8, 2022, 1:39am UTC](https://discuss.elastic.co/t/elasticsearch-post-doc-and-doc-issue/309097/4 "2022-07-08T01:39:37Z")

</div>

Hi @stephenb,

My Elasticsearch version is 7.9

I'm going to change doc to \_doc.

Because the other index can use doc, but only "portstats" can't.

That's the reason I was confusing.

Anyways, I will change the type to \_doc and thank you for the speedy reply.

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [July 8, 2022, 2:01am UTC](https://discuss.elastic.co/t/elasticsearch-post-doc-and-doc-issue/309097/5 "2022-07-08T02:01:07Z")

</div>

> [@Even\_Zhang](#):
>
> Because the other index can use doc, but only "portstats" can't.

I fixed my previous post... an index can only have 1 `_type`... it looks like you set it to `doc` first then tried to use `_doc`... once you set it / use it the first time you must continue to use the same value.

Apologies I should have been more clear ... in 7.x you can only have 1 `_type` per index.  
The correct value is `_doc` but you can still use other values which is highly discourage as that ability has been completely removed in 8.x where the only value `_type` allowed is `_doc`. You will not be able to migrate indices with `_type` set to any other value that `_doc` to version 8.x that is why you should do it now.

---

<div class="post-metadata">

**Author:** ![Even\_Zhang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/even_zhang/32/108012_2.png) [@Even\_Zhang](https://discuss.elastic.co/u/Even_Zhang)\
**Post date:** [July 8, 2022, 5:36am UTC](https://discuss.elastic.co/t/elasticsearch-post-doc-and-doc-issue/309097/6 "2022-07-08T05:36:58Z")

</div>

Thank you for your kind replay and advice.

I will correct the value to \_doc. 👍

---

<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:** [August 5, 2022, 5:37am UTC](https://discuss.elastic.co/t/elasticsearch-post-doc-and-doc-issue/309097/7 "2022-08-05T05:37:33Z")

</div>

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