【发布时间】:2021-02-26 15:27:28
【问题描述】:
我创建了一个 asciifolding.json 文件,其中包含“忽略重音”分析器的配置。
我在顶级对象的字段上使用了@MultiField 注释,这没有问题。
但是,当我在嵌套对象的字段上使用相同的注释时,它会被忽略。
@Document(indexName = "indexName")
@Setting(settingPath = "asciifolding.json")
class TopLevelObject(
@Id
val id: String,
// ----------------------------------------------------------- THIS WORKS
@MultiField(
mainField = Field(type = FieldType.Text, analyzer = "ascii_folding"),
otherFields = [
InnerField(type = FieldType.Keyword, suffix = "keyword")
]
)
val name: String,
val nestedObject: NestedObject
)
@Setting(settingPath = "asciifolding.json")
class NestedObject(
val aField: String,
// --------------------------------------------------------- THIS DOESN'T
@MultiField(
mainField = Field(type = FieldType.Text, analyzer = "ascii_folding"),
otherFields = [
InnerField(type = FieldType.Keyword, suffix = "keyword")
]
)
val anotherField: String
)
GET /indexName/_mapping 的结果:
{
"indexName": {
"mappings": {
"properties": {
"_class": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"id": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
},
"analyzer": "ascii_folding" // APPEARS HERE
},
"nestedObject": {
"properties": {
"aField": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"anotherField": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
} // DOESN'T HERE
}
}
}
}
}
}
}
知道我缺少什么吗?
【问题讨论】:
标签: kotlin spring-data-elasticsearch