# Facing error while create new index

**URL:** <https://discuss.elastic.co/t/facing-error-while-create-new-index/272890>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-monitoring\
**Created:** [May 13, 2021, 8:03am UTC](https://discuss.elastic.co/t/facing-error-while-create-new-index/272890 "2021-05-13T08:03:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dhiraj\_Gurav](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dhiraj_gurav/32/85090_2.png) [@Dhiraj\_Gurav](https://discuss.elastic.co/u/Dhiraj_Gurav)\
**Post date:** [May 13, 2021, 8:03am UTC](https://discuss.elastic.co/t/facing-error-while-create-new-index/272890/1 "2021-05-13T08:03:56Z")

</div>

Hello,  
1)While creating new index as :

PUT logstash-test/logs/1  
{  
"demo" : "demo"  
}

I am facing error as :

{  
"error": {  
"root\_cause": [  
{  
"type": "illegal\_argument\_exception",  
"reason": "Rejecting mapping update to [logstash-test] as the final mapping would have more than 1 type: [\_doc, logs]"  
}  
],  
"type": "illegal\_argument\_exception",  
"reason": "Rejecting mapping update to [logstash-test] as the final mapping would have more than 1 type: [\_doc, logs]"  
},  
"status": 400  
}

2)And when i dont use hypen (-) then it work correct.

PUT logstashtest/logs/1  
{  
"demo" : "demo"  
}

{  
"\_index" : "logstashtest",  
"\_type" : "logs",  
"\_id" : "1",  
"\_version" : 2,  
"result" : "updated",  
"\_shards" : {  
"total" : 2,  
"successful" : 2,  
"failed" : 0  
},  
"\_seq\_no" : 1,  
"\_primary\_term" : 1  
}

 ![Screenshot from 2021-05-13 13-24-28](https://us1.discourse-cdn.com/elastic/original/3X/c/7/c781e6eba745e2e9d56bfc1e13d7fb8f41ad5cd9.png)  
 ![Screenshot from 2021-05-13 13-24-00](https://us1.discourse-cdn.com/elastic/original/3X/c/3/c3897a417926dcbaca13f062c2aaecdf26026ca9.png)

---

<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:** [May 13, 2021, 2:13pm UTC](https://discuss.elastic.co/t/facing-error-while-create-new-index/272890/2 "2021-05-13T14:13:03Z")

</div>

Hi @Dhiraj_Gurav welcome to the community.

One note please refrain from posting images please just post the actual text images are impossible to search and sometimes they do not show up correctly. See below the proper what to do it. Also Please format your code by using the `</>` button above many of use will not answer your post unless you take the time to do that

Your `PUT`s are malformed.

The format is

`PUT /<target>/_doc/<_id>`

See [here](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index_.html) and why `_doc` is needed [here](https://www.elastic.co/guide/en/elasticsearch/reference/current/removal-of-types.html) \<---This is really important

Here is the proper put command.

```
PUT /logstash-test/_doc/1
{
  "demo" : "demo"
}

```

Result

```
{
  "_index" : "logstash-test",
  "_type" : "_doc",
  "_id" : "1",
  "_version" : 1,
  "result" : "created",
  "_shards" : {
    "total" : 2,
    "successful" : 1,
    "failed" : 0
  },
  "_seq_no" : 0,
  "_primary_term" : 1
}

```

The reason yours is failing is that you probably already created the index with some othe `_type` so run

You can take a looks with this.

`GET /logstash-test/_search`

if the `"_type" : "_doc"` if it is anything else it is wrong.

Clean up your index and start again.

`DELETE /logstash-test`

The the PUT command and you should be fine

```
PUT /logstash-test/_doc/1
{
  "demo" : "demo"
}
```

---

<div class="post-metadata">

**Author:** ![Dhiraj](https://avatars.discourse-cdn.com/v4/letter/d/e47c2d/32.png) [@Dhiraj](https://discuss.elastic.co/u/Dhiraj)\
**Post date:** [May 13, 2021, 3:20pm UTC](https://discuss.elastic.co/t/facing-error-while-create-new-index/272890/3 "2021-05-13T15:20:31Z")

</div>

Thanks @stephenb  
This is working. but we have some indexed with customized "\_type" named as "logs".

I used this command.

PUT /logstahshtest/logs/1  
{  
"demo" : "demo"  
}

Result

{  
"\_index" : "logstahshtest",  
"\_type" : "logs",  
"\_id" : "1",  
"\_version" : 1,  
"result" : "created",  
"\_shards" : {  
"total" : 2,  
"successful" : 1,  
"failed" : 0  
},  
"\_seq\_no" : 0,  
"\_primary\_term" : 1  
}

but, when I used a command like this.  
PUT /logstash-test/logs/1  
{  
"demo" : "demo"  
}

Result

```
{

```

"error": {  
"root\_cause": [  
{  
"type": "illegal\_argument\_exception",  
"reason": "Rejecting mapping update to [logstash-test] as the final mapping would have more than 1 type: [\_doc, logs]"  
}  
],  
"type": "illegal\_argument\_exception",  
"reason": "Rejecting mapping update to [logstash-test] as the final mapping would have more than 1 type: [\_doc, logs]"  
},  
"status": 400  
}

when I use the specific word as "logstash " then I am facing this error.

---

<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:** [May 13, 2021, 3:31pm UTC](https://discuss.elastic.co/t/facing-error-while-create-new-index/272890/4 "2021-05-13T15:31:18Z")

</div>

Hi @Dhiraj

You did not format your code, also You did not read the removal of types .. you can not set the \_type which is that you trying to do are doing by using the wrong sytax.

> **[Removal of mapping types | Elasticsearch Guide \[7.12\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/removal-of-types.html)**

This has nothing to do with the word logstash and everything to do with multiple types.

You did not DELETE the old Index then you are still not creating PUT with proper syntax.

I gave you the solution above.

---

<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:** [June 10, 2021, 3:31pm UTC](https://discuss.elastic.co/t/facing-error-while-create-new-index/272890/5 "2021-06-10T15:31:19Z")

</div>

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