一、 创建父文档索引 com_test
PUT http://172.16.31.129:41200/com_test
[C#] 纯文本查看 复制代码
{
"mappings":{
"properties":{
"comname" :{"type": "text", "analyzer" : "standard"},
"fadingdaibiao" :{"type" : "text", "analyzer" :"standard"},
"child": {
"type": "join",
"relations": {
"com":[ "pos" ,"beian","zhuanli"]
}
}
}
},
"settings":{
"index":{
"number_of_shards":5,"number_of_replicas":1
}
}
}
{
"properties": {
"proid": {"type": "integer"},
"ishavebeian": {"type": "integer"},
"ishavepos": {"type": "integer"}
}
}
可以看到上面创建了一个com_test的索引, 父子关系如下:
com是父级, 子集有pos, beian, zhuanli
创建子文档索引
PUT http://172.16.31.129:41200/com_test/_mapping
[C#] 纯文本查看 复制代码
{
"properties": {
"pos_area": {"analyzer": "standard","type": "text"},
"pos_name": {"analyzer": "standard","type": "text"},
"pos_zhaopintype": {"type": "keyword"}
}
}
父子文档,所有的字段均在一个索引里面, 字段也可以进行共用, 主要的区别在于 父子关系上, 就是如下代码:
[C#] 纯文本查看 复制代码
"child": {
"type": "join",
"relations": {
"com":[ "pos" ,"beian","zhuanli"]
}
}
需特别注意的是: 每个索引里面,只能有一个join关系存在
|