Facing error while create new index

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
}


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 PUTs are malformed.

The format is

PUT /<target>/_doc/<_id>

See here and why _doc is needed here <---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"
}

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.

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.

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.

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