Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rejecting mapping update to [] as the final mapping would have more than 1 type

I have create index with explicit mapping:

PUT http://192.168.1.71:9200/items
{
  "mappings": {
    "properties": {
      "name": { 
        "type": "text",
        "fields": {
          "keyword": { 
            "type": "keyword"
          }
        }
      },
            "num": {
          "type": "long"
      }
    }
  }
}

And trying to add document:

POST http://192.168.1.71:9200/items/1
{
  "num" : 1.898,
  "name" : "aaa"   
}

But get the error:

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

Why and how can I fit it?

like image 783
ceth Avatar asked Sep 16 '19 16:09

ceth


1 Answers

You need to specify the document type before the id which is _doc

POST http://192.168.1.71:9200/items/_doc/1
{
  "num" : 1.898,
  "name" : "aaa"   
}
like image 73
Polynomial Proton Avatar answered Oct 21 '22 12:10

Polynomial Proton