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?
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"   
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With