elasticsearch 2.0 parent child 盛大child

elasticsearch 2.0 parent child grandchild

我的操作:

parent:国家,child:分支机构,总公司child:员工

PUT /company { "mappings": { "branch": { "_parent": { "type": "country" } }, "employee": { "_parent": { "type": "branch" } } } }

我要加一个grandchild employee2,parent是branch:

PUT /company/employee2/_mapping { "employee2": { "_parent": { "type": "branch" } } }

我收到错误消息:

{ "error": { "root_cause": [ { "type": "illegal_argument_exception", "reason": "can't add a _parent field that points to an already existing type" } ], "type": "illegal_argument_exception", "reason": "can't add a _parent field that points to an already existing type" }, "status": 400 }

我不知道我该怎么做。有什么建议吗?谢谢。

这是 elasticsearch 2.0 中的限制。 breaking changes in 2.0 中提到了这一点。然而,这背后的原因在文档中并不清楚。

以下是 elasticsearch 开发人员 martijnvg 在 elasticsearch 上发布的讨论帖:

a new child type can't point to an existing type as parent.

This has to do with the fact that with the new parent/child implementation both parent and child types store ids in a join field. If type becomes a parent after it has been created then parent documents may have been indexed that didn't store their id in the join field. For this reason this restriction exists.

This only applies for new indices created after the upgrade to ES 2.0. For migration purposes this restriction doesn't apply for indices created before the upgrade to ES 2.0. In fact on created on ES 1.x and before the old parent/child implementation is being used.

您可以在这里阅读: https://discuss.elastic.co/t/adding-child-types-in-2-0/33267

好的 我发现了问题 - 您无法使用现有类型创建父子关系 删除索引后一切正常