In several pages in Elasticsearch documentation is mentioned how to query a multi-type index.
But I failed to create one at the first place.

Here is my minimal example (on a Elasticsearch 6.x server):

PUT /myindex
{
  "settings" : {
    "number_of_shards" : 1
  }
}

PUT /myindex/people/123
{
  "first name": "John",
  "last name": "Doe"
}

PUT /myindex/dog/456
{
  "name": "Rex"
}

Index creation and fist insert did well, but at the dog type insert attempt:

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

But this is exactly what I’m trying to do, buddy! Having “more than 1 type” in my index.

Do you know what I have to change in my calls to achieve this?

Many thanks.

2

Multiple mapping types are not supported from Elastic 6.0.0 onwards. See breaking changes for details.

You can still effectively use multiple types by implementing your own custom type field.

For example:

{
    "mappings": {
        "doc": {
            "properties": {
                "type": {
                    "type": "keyword"
                },
                "first_name": {
                    "type": "text"
                },
                "last_name": {
                    "type": "text"
                }

            }
        }
    }
}

This is described in removal of types.