如果我执行以下操作,则会发生错误:
thing
)thing
个字段中只有一个"index": "not_analyzed"
以上呼叫可以完成上述操作:
DELETE /test/
PUT /test/
{
"mappings": {
"product": {
"properties": {
"thing": {
"type": "string",
"index": "not_analyzed"
}
}
},
"page": {
"properties": {
"thing": {
"type": "string"
}
}
}
}
}
然后会出现以下错误:
# DELETE /test/
{ ... }
# PUT /test/
{
"error": {
"root_cause": [
{
"type": "mapper_parsing_exception",
"reason": "Failed to parse mapping [page]: Mapper for [thing] conflicts with existing mapping in other types:\n[mapper [thing] has different [index] values, mapper [thing] has different [omit_norms] values, cannot change from disable to enabled, mapper [thing] has different [analyzer], mapper [thing] is used by multiple types. Set update_all_types to true to update [omit_norms] across all types., mapper [thing] is used by multiple types. Set update_all_types to true to update [search_analyzer] across all types., mapper [thing] is used by multiple types. Set update_all_types to true to update [search_quote_analyzer] across all types.]"
}
],
"type": "mapper_parsing_exception",
"reason": "Failed to parse mapping [page]: Mapper for [thing] conflicts with existing mapping in other types:\n[mapper [thing] has different [index] values, mapper [thing] has different [omit_norms] values, cannot change from disable to enabled, mapper [thing] has different [analyzer], mapper [thing] is used by multiple types. Set update_all_types to true to update [omit_norms] across all types., mapper [thing] is used by multiple types. Set update_all_types to true to update [search_analyzer] across all types., mapper [thing] is used by multiple types. Set update_all_types to true to update [search_quote_analyzer] across all types.]",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "Mapper for [thing] conflicts with existing mapping in other types:\n[mapper [thing] has different [index] values, mapper [thing] has different [omit_norms] values, cannot change from disable to enabled, mapper [thing] has different [analyzer], mapper [thing] is used by multiple types. Set update_all_types to true to update [omit_norms] across all types., mapper [thing] is used by multiple types. Set update_all_types to true to update [search_analyzer] across all types., mapper [thing] is used by multiple types. Set update_all_types to true to update [search_quote_analyzer] across all types.]"
}
},
"status": 400
}
有人可以解释为什么会这样吗?这是一个错误吗?
答案 0 :(得分:2)
弹性"类型"机制是虚拟的。意思是,在较低级别(= lucene),索引的所有文档都是相同的"类型"。弹性"类型"除法仅通过添加" _type"字段并通过它过滤。这意味着您不能(在一个索引上)具有相同field_name和不同映射的2种类型 - 因为在较低级别它们是相同类型且它们处于冲突中! 你定义了" thing"在"产品"输入not_analyzed,然后输入" page"你将其定义为" string"默认为"分析" - 这是一个不同的映射,发生冲突!要么使它们相同,要么改变其中一个字段名称。