我用弹性记录了以下结构:
PUT /movies
{
"mappings": {
"title": {
"properties": {
"title": {
"type": "string",
"fields": {
"de": {
"type": "string",
"analyzer": "german"
},
"en": {
"type": "string",
"analyzer": "english"
},
"fr": {
"type": "string",
"analyzer": "french"
},
"es": {
"type": "string",
"analyzer": "spanish"
}
}
}
}
}
}
}
但是当我试图记录这样的值时:
PUT movies/_doc/2
{
"title": "fox",
"field": "en"
}
我收到以下错误:
{
"error": {
"root_cause": [
{
"type": "illegal_argument_exception",
"reason": "Rejecting mapping update to [movies] as the final mapping would have more than 1 type: [_doc, title]"
}
],
"type": "illegal_argument_exception",
"reason": "Rejecting mapping update to [movies] as the final mapping would have more than 1 type: [_doc, title]"
},
"status": 400
}
也许我做错了,因为我刚接触弹性。我的想法是创建一个一对一的映射,当我以任何一种语言搜索Fox时,由于它们都记录在数据库中,因此只返回英文结果。
答案 0 :(得分:1)
您的映射表示映射类型为“标题”,但是在创建文档时,您使用PUT movies/_doc/2
表示映射类型_doc
(该映射类型不存在),因此ES会尝试自动创建它。禁止使用具有多种映射类型的ES的较新版本。
您应该将其更改为:PUT movies/title/2