Elasticsearch 6.2 Multiples types (parent-child) in the same index

Hello,

I use Elasticsearch 6.2.1. I have to create multiples types in the same index as (parent-child relationship). i read here https://www.elastic.co/guide/en/elasticsearch/reference/current/removal-of-types.html:

  • this version don't support multiples types
  • by the way any, no later version will support it

i have read more topics in this forum but i didn't see an example that joins my case

i define it with join field concept:

POST my_index/parent_type
{
  "mappings": {
    "_doc": {
      "properties": {
        "uid": {
          "type": "text",
          "analyzer": "my_analyzer"
        },
        "email": {
          "type": "text",
          "analyzer": "my_analyzer"
        },
        "profile": {
          "type": "nested",
          "properties": {
            "firstName": {
              "type": "text",
              "analyzer": "my_analyzer"
            },
            "lastName": {
              "type": "text",
              "analyzer": "my_analyzer"
            },
            "company": {
              "type": "text",
              "analyzer": "my_analyzer"
            }
          }
        },
        "stats": {
          "type": "nested",
          "properties": {
            "totalPoints": {
              "type": "integer"
            }
          }
        }
      }
    }
  }
}


POST my_index/child_type
{
  "mappings": {
    "_doc": {
      "properties": {
        "parent_uid": {
          "type": "join",
          "relations": {
            "parent_type": "child_type"
          }
        },
        "uid": {
          "type": "text",
          "analyzer": "my_analyzer"
        },
        "name": {
          "type": "text",
          "analyzer": "my_analyzer"
        },
       
    }
  }
}

it gives:

{
  "error": {
    "root_cause": [
      {
        "type": "illegal_argument_exception",
        "reason": "Rejecting mapping update to [carrot-dev] as the final mapping would have more than 1 type: [users, users-following]"
      }
    ],
    "type": "illegal_argument_exception",
    "reason": "Rejecting mapping update to [carrot-dev] as the final mapping would have more than 1 type: [users, users-following]"
  },
  "status": 400
}

Thanks for your help.

I solved this by using an index per document type.

https://www.elastic.co/guide/en/elasticsearch/reference/master/removal-of-types.html

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