elasticsearch 2.0父子孙 [英] elasticsearch 2.0 parent child grandchild

查看:511
本文介绍了elasticsearch 2.0父子孙的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的操作:

parent:country,child:branch,grandchild:employee

parent: country, child: branch, grandchild: employee


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

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

我想添加一个孙子的employee2,父是分支:

I want add a grandchild employee2, parent is branch:


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

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

我收到错误讯息:


{error:{
root_cause:[
{
type:illegal_argument_exception,
reason:无法添加指向已存在类型的_parent字段
}
],
type:illegal_argument_exception,
reason:无法添加指向已存在类型的_parent字段},status:400}

{ "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 }

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

I don't know how can i do. Have any suggestion? Thanks.

推荐答案

这是在elasticsearch 2.0中强加的限制。
这是在在2.0 。但是,这个背后的原因在文档中是不清楚的。

This is a restriction imposed in elasticsearch 2.0. This is mentioned in breaking changes in 2.0. However the reason behind this this is not clear in the document.

下面是弹性搜索器上发布的一个弹性搜索开发人员讨论的主题:

Below is what martijnvg an elasticsearch developer posted on elasticsearch discuss threads:


一个新的子类型不能指向现有类型作为父级。

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

这与事实有关与新的父/子
实现父和子类型在连接字段中存储ID。
如果类型在创建后成为父级,那么父
文档可能已被编入索引,并没有将其id存储在加入
字段中。因此,此限制存在。

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.

这仅适用于升级到ES 2.0后创建的新索引。
对于迁移目的,此限制不适用于在升级到ES 2.0之前创建的索引
。实际上,在使用旧的父/子实现之前,在ES 1.x和
上创建。

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

这篇关于elasticsearch 2.0父子孙的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆