elasticsearch的父子,elasticsearch 2.0父子孙

My operation:

parent: country, child: branch, grandchild: employee

PUT /company { "mappings": {

"branch": {

"_parent": {

"type": "country"

}

},

"employee": {

"_parent": {

"type": "branch"

}

} } }

I want add a grandchild employee2, parent is branch:

PUT /company/employee2/_mapping { "employee2": {

"_parent": {

"type": "branch"

} } }

I get wrong message:

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

解决方案

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.

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值