reindex error when upgrading to elasticsearch 7

杀马特。学长 韩版系。学妹 提交于 2020-02-06 15:43:49

问题


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:

  1. 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
  2. If you have indices with multiple types, you'll need to re-index them per document type.
  3. Custom type names like products in your case should be replaced with _doc or doc. Ideally, type name should not be there when defining mappings. See this.
  4. 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.

  5. Have a look at this Upgrade link.

Hope this helps



来源:https://stackoverflow.com/questions/58629372/reindex-error-when-upgrading-to-elasticsearch-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!