Elasticsearch issue types removal

梦想与她 提交于 2021-02-05 08:33:12

问题


I am trying to run the below code in Python using Elasticsearch Ver 7.1, however the following errors come up:

ElasticsearchDeprecationWarning: [types removal] Using include_type_name in put mapping requests is deprecated. The parameter will be removed in the next major version.
  client.indices.put_mapping(index=indexName,doc_type='diseases', body=diseaseMapping, include_type_name=True)

followed by:

ElasticsearchDeprecationWarning: [types removal] Specifying types in document index requests is deprecated, use the typeless endpoints instead (/{index}/_doc/{id}, /{index}/_doc, or /{index}/_create/{id}).
  client.index(index=indexName,doc_type=docType, body={"name": disease,"title":currentPage.title,"fulltext":currentPage.content})

How I am supposed to amend my code to make it (see here) work in line with Elasticsearch 7X version? Any kind of help would be much appreciated.


回答1:


This is just a warning right now, but it will become an error in Elasticsearch 8.

From last few version, Elasticsearch has been planning the removal of index types inside an index

  1. ES5 - Setting index.mapping.single_type: true on an index will enable the single-type-per-index behavior which will be enforced in 6.0.
  2. In ES6 - you can't have more than 1 index type inside 1 index
  3. In ES7 - the concept of types inside an index has been deprecated
  4. In ES8 - it will be removed, and you can't use types for query or while inserting documents

My suggestion would be to design an application and mapping in such a way that it doesn't include type parameter in index

To know the reason why elastic search has done this here is a link: https://www.elastic.co/guide/en/elasticsearch/reference/current/removal-of-types.html#_why_are_mapping_types_being_removed




回答2:


A common issue (and difficult to spot) for this error message could be misspelling the endpoint, e.g.:

Misspelled:

/search

Correct:

/_search

Double check if your endpoint is correct as ElasticSearch may think you are trying to manipulate (add, update, remove) a document and you are giving a type, which is not the case (you are trying to call an endpoint).



来源:https://stackoverflow.com/questions/62322613/elasticsearch-issue-types-removal

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