问题
We are currently using the searchkick gem and it works great. Recently I tried upgrading elasticsearch to 7 in my local development environment. I got it up and running using homebrew ( after researching that I needed to run rm -fr /usr/local/var/lib/elasticsearch
). When I went to reindex one of my models I got the following mapping error:
Elasticsearch::Transport::Transport::Errors::BadRequest: [400] {"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"Root mapping definition has unsupported parameters: [cosmetics/products : {properties={product={type=keyword}}}]"}],"type":"mapper_parsing_exception","reason":"Failed to parse mapping [_doc]: Root mapping definition has unsupported parameters: [cosmetics/products : {properties={product={type=keyword}}}]","caused_by":{"type":"mapper_parsing_exception","reason":"Root mapping definition has unsupported parameters: [cosmetics/products : {properties={product={type=keyword}}}]"}},"status":400}
This error does not occur when using elasticsearch 6.8.4. Can anyone point to me to a resource for resolving this issue?
回答1:
Mapping type is not supported in version 7.
To solve this, remove all mapping types (_doc for example)
Indices created in Elasticsearch 6.0.0 or later may only contain a single mapping type. Indices created in 5.x with multiple mapping types will continue to function as before in Elasticsearch 6.x. Types will be deprecated in APIs in Elasticsearch 7.0.0, and completely removed in 8.0.0.
Check this out
And this
回答2:
In addition to the excellent answer by @Assael Azran and the great link he shared, here's some additional information:
- If you have indices created in 5.x or before, you'll need to re-index them when you are in 6.8 BEFORE upgrading to 7.x
- If you have indices with multiple types, you'll need to re-index them per document type.
- Custom type names like
products
in your case should be replaced with_doc
ordoc
. Ideally, type name should not be there when defining mappings. See this. All your 5.x or before snapshots, if any, will not work on 7.x. So you'll need to restore the indices from those snapshots when you are in 6.8, then re-index the indices, then again snapshot. You can then delete the indices and also delete older snapshots.
Have a look at this Upgrade link.
Hope this helps
来源:https://stackoverflow.com/questions/58629372/reindex-error-when-upgrading-to-elasticsearch-7