How to create a dynamic template for parent-child relationship in Elasticsearch 6.x version


(Sudeepkumarnair) #1

I am having a hard time in figuring the dynamic template which can define the parent-child relationship for ES 6.x . Any examples are welcome ...

Basically, I have a root and child documents (parent-child). Currently, I do the following explicit mapping:

PUT index-2018.06.05
{
"mappings": {
"_doc": {
"properties": {
"join_field": {
"type": "join",
"relations": {
"root": "child"
}
}
}
}
}
}

Is it possible for me to define the same as part of a dynamic template?


(Sudeepkumarnair) #2

ANYONE ?


(Sudeepkumarnair) #3

I managed to the same with two templates with different ordering numbers. Hope it helps someone.
{
"index_patterns": [
"discovery-*"
],
"order": 0,
"mappings": {
"_doc": {
"properties": {
"join_field": {
"type": "join",
"relations": {
"topo": "document"
}
}
}
}
}
}

PUT _template/discovery-events
{
"order": 1,
"index_patterns": [
"discovery-"
],
"settings": {
"index": {
"number_of_shards": "1",
"number_of_replicas": "1"
}
},
"mappings": {
"_doc": {
"dynamic_templates": [
{
"timestamp": {
"mapping": {
"format": "strict_date_optional_time||epoch_millis",
"type": "date"
},
"match_mapping_type": "long",
"path_match": "timestamp"
}
},
{
"name": {
"mapping": {
"type": "keyword"
},
"match_mapping_type": "string"
}
},
{
"namespace": {
"mapping": {
"type": "keyword"
},
"match_mapping_type": "string"
}
},
{
"doctype": {
"mapping": {
"type": "keyword"
},
"match_mapping_type": "string"
}
},
{
"dimensions": {
"mapping": {
"type": "nested",
"eager_global_ordinals": true
},
"match": "
",
"match_mapping_type": "object"
}
},
{
"values": {
"mapping": {
"type": "nested",
"eager_global_ordinals": true
},
"match": "*",
"match_mapping_type": "object"
}
}
]
}
},
"aliases": {}
}


(system) #4

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.