# Create index questions

**URL:** https://discuss.elastic.co/t/create-index-questions/156771
**Category:** Elasticsearch
**Created:** [November 15, 2018, 3:08am UTC](https://discuss.elastic.co/t/create-index-questions/156771 "2018-11-15T03:08:07Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![liuuu](https://avatars.discourse-cdn.com/v4/letter/l/bbe5ce/32.png) [@liuuu](https://discuss.elastic.co/u/liuuu)
#### Post date: [November 15, 2018, 3:08am UTC](https://discuss.elastic.co/t/create-index-questions/156771/1 "2018-11-15T03:08:08Z")

</div>

```
PUT test
{
    "settings" : {
        "number_of_shards" : 1
    },
    "mappings" : {
        "_doc" : {
            "properties" : {
                "field1" : { "type" : "text" }
            }
        }
    }
}

```

what does `_doc` means when creating a `index`?  
Can I specific a `typename` instead of `_doc`, as `student` replacing `_doc`

```
PUT test
{
    "settings" : {
        "number_of_shards" : 1
    },
    "mappings" : {
        "students" : {
            "properties" : {
                "field1" : { "type" : "text" }
            }
        }
    }
}
```

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [November 15, 2018, 4:02am UTC](https://discuss.elastic.co/t/create-index-questions/156771/2 "2018-11-15T04:02:19Z")

</div>

> [@liuuu](#):
>
> what does `_doc` means when creating a `index` ?

That is the `_type`. This is deprecated and will be removed in 7.0, so we would suggest not using anything but that default value.

> [@liuuu](#):
>
> Can I specific a `typename` instead of `_doc` , as `student` replacing `_doc`

You should add this as a new field instead.

---

<div class="post-metadata">

### Author: ![liuuu](https://avatars.discourse-cdn.com/v4/letter/l/bbe5ce/32.png) [@liuuu](https://discuss.elastic.co/u/liuuu)
#### Post date: [November 15, 2018, 6:33am UTC](https://discuss.elastic.co/t/create-index-questions/156771/3 "2018-11-15T06:33:53Z")

</div>

`/index/${typename}/`

I wanna create a mapping for this `type`  
`/test/students` as for `students`  
how does it become a `field` name other than a `typename`

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [November 15, 2018, 7:28am UTC](https://discuss.elastic.co/t/create-index-questions/156771/4 "2018-11-15T07:28:30Z")

</div>

Don't do that.

Put `"typename": "student"` in your document.

---

<div class="post-metadata">

### Author: ![liuuu](https://avatars.discourse-cdn.com/v4/letter/l/bbe5ce/32.png) [@liuuu](https://discuss.elastic.co/u/liuuu)
#### Post date: [November 15, 2018, 8:44am UTC](https://discuss.elastic.co/t/create-index-questions/156771/5 "2018-11-15T08:44:25Z")

</div>

Sorry, I am quite new to elastic.  
the purpose is to create a index name `test` and initialize the mapping of a `typename = "students"`

```
PUT test
{
  "settings": {
        "number_of_replicas": 1,
        "number_of_shards": 1
  },
  "mappings" : {
    "_doc" : {
        "properties" : {
            "field1" : { "type" : "text" }
        }
    }
 }
}

```

above that's referring to the docs,  
I am quite confusing here(what is `_doc` means here)  
So I am intent to replace `_doc` to `students`, because `students` is my `table` name(in elastic world `typename`)

**probably I misused the word `typename`**  
below is what I want as a result for each document  
` _index: "test", _type: "students"`

As your said:

> Put `"typename": "student"` in your document.

I don't really know

1. where should I put my `"typename": "student"` to.
2. And how to achieve my purpose `initialize a index with a typename(table name) as well as set the mapping of the typename's fields`

Many thanks.

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [November 15, 2018, 11:52pm UTC](https://discuss.elastic.co/t/create-index-questions/156771/6 "2018-11-15T23:52:14Z")

</div>

Do this;

```auto
PUT test
{
  "settings": {
        "number_of_replicas": 1,
        "number_of_shards": 1
  },
  "mappings" : {
    "_doc" : {
        "properties" : {
            "field1" : { "type" : "text" },
            "typename" : { "type" : "text" }
        }
    }
 }
}

```

Ignore `_doc`, ignore `_type`, they are deprecated features and using them will only cause more problems.

---

<div class="post-metadata">

### Author: ![liuuu](https://avatars.discourse-cdn.com/v4/letter/l/bbe5ce/32.png) [@liuuu](https://discuss.elastic.co/u/liuuu)
#### Post date: [November 16, 2018, 1:35am UTC](https://discuss.elastic.co/t/create-index-questions/156771/7 "2018-11-16T01:35:04Z")

</div>

Sorry, I thought you still misunderstand.  
I wanna the type be the table name . like this `test/students/1`

And, specify the filed such as `name, gender, id, age` of `students` not on `index`,  
`_index: "test", _type: "students"`

So, I am intent to do

```
PUT test
 "mappings" : {
    "students" : {
        "properties" : {
            "field1" : { "type" : "text" }
        }
    }
 }

```

* * *

in your last reply

```
PUT test
{
  "settings": {
        "number_of_replicas": 1,
        "number_of_shards": 1
  },
  "mappings" : {
    "_doc" : {
        "properties" : {
            "field1" : { "type" : "text" },
            "typename" : { "type" : "text" }
        }
    }
 }
}

```

I thought you still used the `_doc`.  
Is there something I misunderstand about `mappings`?

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [November 16, 2018, 4:27am UTC](https://discuss.elastic.co/t/create-index-questions/156771/8 "2018-11-16T04:27:22Z")

</div>

Please read [https://www.elastic.co/blog/removal-of-mapping-types-elasticsearch](https://www.elastic.co/blog/removal-of-mapping-types-elasticsearch).

As I have been saying - Do Not Use Types. They will be removed very soon.  
If you use this type then you will need to make more changes in the very near future.

---

<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: [December 14, 2018, 4:36am UTC](https://discuss.elastic.co/t/create-index-questions/156771/9 "2018-12-14T04:36:41Z")

</div>

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