# Can't use \_doc as type despite it being declared the preferred method

**URL:** https://discuss.elastic.co/t/cant-use-doc-as-type-despite-it-being-declared-the-preferred-method/113837
**Category:** Elasticsearch
**Created:** [January 2, 2018, 9:05pm UTC](https://discuss.elastic.co/t/cant-use-doc-as-type-despite-it-being-declared-the-preferred-method/113837 "2018-01-02T21:05:19Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![percona.jayj](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/percona.jayj/32/25401_2.png) [@percona.jayj](https://discuss.elastic.co/u/percona.jayj)
#### Post date: [January 2, 2018, 9:05pm UTC](https://discuss.elastic.co/t/cant-use-doc-as-type-despite-it-being-declared-the-preferred-method/113837/1 "2018-01-02T21:05:19Z")

</div>

Ok, I'm at a loss. I'm starting to work with 6.0 and I read [here](https://www.elastic.co/guide/en/elasticsearch/reference/6.x/removal-of-types.html#_schedule_for_removal_of_mapping_types) that the preferred type name in 6.x is '\_doc'. However, when I try to PUT a new document, I get an error from the (6.0.1) server:

> Document mapping type name can't start with '\_'

I am using the precise example from the [6.x manual for UPDATE](https://www.elastic.co/guide/en/elasticsearch/reference/6.x/docs-update.html) and further if I use 'doc' instead '\_doc', it works fine.

Is the joke on me?

```
$ curl localhost:32798
{
  "name" : "IsUdPpi",
  "cluster_name" : "docker-cluster",
  "cluster_uuid" : "0pvQUrwaSc-wO9f7XAA87w",
  "version" : {
    "number" : "6.0.1",
    "build_hash" : "601be4a",
    "build_date" : "2017-12-04T09:29:09.525Z",
    "build_snapshot" : false,
    "lucene_version" : "7.0.1",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  },
  "tagline" : "You Know, for Search"
}

$ curl -XPUT 'localhost:32798/test/_doc/1?pretty' -H 'Content-Type: application/json' -d'
{
    "counter" : 1,
    "tags" : ["red"]
}
'
{
  "error" : {
    "root_cause" : [
      {
        "type" : "invalid_type_name_exception",
        "reason" : "Document mapping type name can't start with '_', found: [_doc]"
      }
    ],
    "type" : "invalid_type_name_exception",
    "reason" : "Document mapping type name can't start with '_', found: [_doc]"
  },
  "status" : 400
}

$ curl -XPUT 'localhost:32798/test/doc/2?pretty' -H 'Content-Type: application/json' -d'
{
    "counter" : 1,
    "tags" : ["red"]
}
'
{
  "_index" : "test",
  "_type" : "doc",
  "_id" : "2",
  "_version" : 1,
  "result" : "created",
  "_shards" : {
    "total" : 2,
    "successful" : 1,
    "failed" : 0
  },
  "_seq_no" : 0,
  "_primary_term" : 1
}
```

---

<div class="post-metadata">

### Author: ![percona.jayj](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/percona.jayj/32/25401_2.png) [@percona.jayj](https://discuss.elastic.co/u/percona.jayj)
#### Post date: [January 2, 2018, 9:25pm UTC](https://discuss.elastic.co/t/cant-use-doc-as-type-despite-it-being-declared-the-preferred-method/113837/2 "2018-01-02T21:25:44Z")

</div>

Apparently I shouldn't read the 6.x documentation

References \_doc:  
[https://www.elastic.co/guide/en/elasticsearch/reference/6.x/removal-of-types.html#\_schedule\_for\_removal\_of\_mapping\_types](https://www.elastic.co/guide/en/elasticsearch/reference/6.x/removal-of-types.html#_schedule_for_removal_of_mapping_types)

Most references to \_doc are gone:  
[https://www.elastic.co/guide/en/elasticsearch/reference/current/removal-of-types.html#\_schedule\_for\_removal\_of\_mapping\_types](https://www.elastic.co/guide/en/elasticsearch/reference/current/removal-of-types.html#_schedule_for_removal_of_mapping_types)

Clear as mud

---

<div class="post-metadata">

### Author: ![SKumarMN](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/skumarmn/32/27537_2.png) [@SKumarMN](https://discuss.elastic.co/u/SKumarMN)
#### Post date: [January 29, 2018, 6:51am UTC](https://discuss.elastic.co/t/cant-use-doc-as-type-despite-it-being-declared-the-preferred-method/113837/3 "2018-01-29T06:51:12Z")

</div>

Facing the same issue.

---

<div class="post-metadata">

### Author: ![HVictor](https://avatars.discourse-cdn.com/v4/letter/h/e0b2c6/32.png) [@HVictor](https://discuss.elastic.co/u/HVictor)
#### Post date: [February 13, 2018, 1:52am UTC](https://discuss.elastic.co/t/cant-use-doc-as-type-despite-it-being-declared-the-preferred-method/113837/4 "2018-02-13T01:52:01Z")

</div>

Same issue. Did you get an answer somewhere?

---

<div class="post-metadata">

### Author: ![percona.jayj](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/percona.jayj/32/25401_2.png) [@percona.jayj](https://discuss.elastic.co/u/percona.jayj)
#### Post date: [February 13, 2018, 12:23pm UTC](https://discuss.elastic.co/t/cant-use-doc-as-type-despite-it-being-declared-the-preferred-method/113837/5 "2018-02-13T12:23:41Z")

</div>

The answer seems to be that they were going to standardize on `_doc`, but changed their minds at some point. AFAICT, you can standardize on whatever you like, just not something that has an underscore. I chose 'doc'.

---

<div class="post-metadata">

### Author: ![HVictor](https://avatars.discourse-cdn.com/v4/letter/h/e0b2c6/32.png) [@HVictor](https://discuss.elastic.co/u/HVictor)
#### Post date: [February 13, 2018, 8:16pm UTC](https://discuss.elastic.co/t/cant-use-doc-as-type-despite-it-being-declared-the-preferred-method/113837/6 "2018-02-13T20:16:36Z")

</div>

What version of Elastic are you using?

I was using 6.1.3 and \_doc was a problem. Then switched to 6.2.1 and you can use \_doc without any issues.

Any other name starting with \_, however, gives an error:  
"type": "invalid\_type\_name\_exception",  
"reason": "mapping type name [_vdoc] can't start with '_' unless it is called [\_doc]"

It seems 6.2.1 is in line with the documentation

---

<div class="post-metadata">

### Author: ![percona.jayj](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/percona.jayj/32/25401_2.png) [@percona.jayj](https://discuss.elastic.co/u/percona.jayj)
#### Post date: [February 13, 2018, 8:29pm UTC](https://discuss.elastic.co/t/cant-use-doc-as-type-despite-it-being-declared-the-preferred-method/113837/7 "2018-02-13T20:29:12Z")

</div>

I believe I was testing 6.1 or maybe a 6.0 version at the time. I can't upgrade to 6.x yet because of [Creating new types in 6.0](https://discuss.elastic.co/t/creating-new-types-in-6-0/111350/6).

---

<div class="post-metadata">

### Author: ![Lory\_Hou](https://avatars.discourse-cdn.com/v4/letter/l/ebca7d/32.png) [@Lory\_Hou](https://discuss.elastic.co/u/Lory_Hou)
#### Post date: [February 21, 2018, 7:27am UTC](https://discuss.elastic.co/t/cant-use-doc-as-type-despite-it-being-declared-the-preferred-method/113837/8 "2018-02-21T07:27:08Z")

</div>

change \_doc to doc

---

<div class="post-metadata">

### Author: ![jasontedor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasontedor/32/66992_2.png) [@jasontedor](https://discuss.elastic.co/u/jasontedor)
#### Post date: [February 22, 2018, 2:49am UTC](https://discuss.elastic.co/t/cant-use-doc-as-type-despite-it-being-declared-the-preferred-method/113837/9 "2018-02-22T02:49:40Z")

</div>

Sorry for the confusion, we addressed this in 6.2.0: [https://github.com/elastic/elasticsearch/pull/27816](https://github.com/elastic/elasticsearch/pull/27816)

---

<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: [March 22, 2018, 2:50am UTC](https://discuss.elastic.co/t/cant-use-doc-as-type-despite-it-being-declared-the-preferred-method/113837/10 "2018-03-22T02:50:19Z")

</div>

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