Reputation: 2908
An error occurs if I do the following:
thing
)thing
fields have "index": "not_analyzed"
The above can be done with the following calls:
DELETE /test/
PUT /test/
{
"mappings": {
"product": {
"properties": {
"thing": {
"type": "string",
"index": "not_analyzed"
}
}
},
"page": {
"properties": {
"thing": {
"type": "string"
}
}
}
}
}
The following error will then occur:
# 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
}
Can someone explain why this is the case? Is this a bug?
Upvotes: 0
Views: 265
Reputation: 1082
Elastic "types" mechanism is virtual. Meaning, on the lower level (=lucene) all documents of an index are of the same "type". Elastic "type" division is done only by adding a "_type" field and filtering by it. That means you cannot have (on one index) 2 types with the same field_name and a different mapping - because on the lower level they are of the same type and they are in a conflict! You defined "thing" in "product" type as not_analyzed, and in "page" you define it as "string" which defaults to "analyzed" - this is a different mapping and a conflict occurs! Either make them both the same or change one of the field names.
Upvotes: 2