我将有一个包含多个字段的文档。让我们说“标题”、“元1”、“元2”、“全身”。我想用几种不同的方式对它们进行索引(原始的,没有停止的词干--单词,片语,同义词等等)。因此,我将有这样的字段:title.stemming、title.shingles、meta1.stemming、meta1.shingles等。
是否必须复制粘贴每个字段的映射定义?或者,是否有可能为所有索引/分析方法创建一个定义,然后只将其应用于4个顶级字段中的每一个?如果是,怎么做?
mappings:
my_type:
properties:
title:
type: string
fields:
shingles:
type: string
analyzer: my_shingle_analyzer
stemming:
type: string
analyzer: my_stemming_analyzer
meta1:
... <-- do i have to repeat everything here?
meta2:
... <-- and here?
full_body:
... <-- and here?发布于 2016-01-18 12:00:32
在您的示例中,可以将动态模板与match_mapping_type设置一起使用,以便对所有字符串字段应用相同的设置:
{
"mappings": {
"my_type": {
"dynamic_templates": [
{
"strings": {
"match_mapping_type": "string",
"mapping": {
"type": "string",
"fields": {
"shingles": {
"type": "string",
"analyzer": "my_shingle_analyzer"
},
"stemming": {
"type": "string",
"analyzer": "my_stemming_analyzer"
}
, ... other sub-fields and analyzers
}
}
}
}
]
}
}
}因此,无论何时索引字符串字段,都会根据定义的模板创建其映射。还可以使用match设置将映射限制为特定的字段名。
https://stackoverflow.com/questions/34854089
复制相似问题