【发布时间】:2021-02-15 07:20:24
【问题描述】:
我有一个索引模板,它有一个属性,该属性有一个名为 meta 的动态对象。 我还有一个动态模板规则,它将字符串类型的所有元属性设置为关键字并将它们添加到另一个名为 catch_all 的字段。
有一个特定的属性,extendedDescription,我不想作为关键字添加,我想明确地将它的类型设置为文本。我通过为该设置添加显式设置来做到这一点。
但是,该属性可以出现在我的元对象的不同父属性中,例如在 "meta.none.extendedDescription" 或 "meta.it.extendedDescription" 或 "meta.en.extendedDescription" 中。
这是我现在正在使用的,它可以工作,但你可以看到我必须为每次出现的扩展描述“硬编码”设置。 (并且可以很好地使用我已经拥有的动态模板)
{
"order": 0,
"index_patterns": [
"my-poi-*"
],
"settings": {},
"mappings": {
"doc": {
"dynamic_templates": [
{
"string_fields_all": {
"match_mapping_type": "string",
"match": "*",
"mapping": {
"analyzer": "analyzer_keyword",
"type": "keyword",
"copy_to": "catch_all"
}
}
}
],
"dynamic": false,
"properties": {
"name": {
"type": "keyword",
"copy_to": "catch_all"
},
"meta": {
"type": "object",
"dynamic": true,
"properties": {
"none": {
"type": "object",
"dynamic": true,
"properties": {
"extendedDescription": {
"type": "text",
"index": false
}
}
},
"it": {
"type": "object",
"dynamic": true,
"properties": {
"extendedDescription": {
"type": "text",
"index": false
}
}
},
"en": {
"type": "object",
"dynamic": true,
"properties": {
"extendedDescription": {
"type": "text",
"index": false
}
}
}
}
},
"catch_all": {
"type": "text"
}
}
}
},
"aliases": {}
}
有没有一种方法可以使用通配符或规则来允许将此属性设置为文本,无论它出现在我的元对象中的什么位置? (它总是有"meta.{some-lang-code}.extendedDescription"的模式
我试过了,但没用:
"meta": {
"type": "object",
"dynamic": true,
"properties": {
"*.extendedDescription": {
"type": "text",
"index": false
}
},
【问题讨论】:
标签: elasticsearch