How to create a child type when its parent type is already exist in Elasticsearch 2.X?

I know parent/child has been rewritten in ES2.X, and the mapping for the parent type can be added at the same time as the mapping for the child type, but cannot be added before the child type.

But I think it's not logical. In my situation, I cannot create all children types with their parent type mapping at the same time. I really need to create a child type when its parent type is already exist.

Please give some suggestions.

1 Like

There is no workaround for this at the moment. If you want to add a new child mapping pointing to an existing parent mapping then you need to reindex. (the reindex api can make this a bit easier)

I think maybe ES can relax this constraint a bit. Just to understand your use case correctly: you only introduce new child mappings that point to a parent mapping that already has other child mappings? If so then I think this maybe can be allowed.

What ES can't support is adding child mappings that point to a parent mapping that has no other child mappings yet.

1 Like

thx
In my case, parent mapping already has child mapping.

I opened an issue for this: https://github.com/elastic/elasticsearch/issues/17956

1 Like

Thank you!