Elasticsearch 问题类型移除

Jan*_*nek 4 elasticsearch

我正在尝试使用 Elasticsearch Ver 7.1 在 Python 中运行以下代码,但是出现以下错误:

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)
Run Code Online (Sandbox Code Playgroud)

其次是:

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})
Run Code Online (Sandbox Code Playgroud)

我应该如何修改我的代码以使其(请参阅此处)与 Elasticsearch 7X 版本一致?任何形式的帮助将不胜感激。

gau*_*620 6

现在这只是一个警告,但它会在 Elasticsearch 8 中变成一个错误。

从最近几个版本开始,Elasticsearch 一直在计划删除索引内的索引类型

  1. ES5 - 在索引上设置 index.mapping.single_type: true 将启用单类型每个索引行为,这将在 6.0 中强制执行。
  2. 在 ES6 中 - 1 个索引内不能有超过 1 个索引类型
  3. 在 ES7 中 - 索引内的类型概念已被弃用
  4. 在 ES8 中 - 它将被删除,并且您不能在查询或插入文档时使用类型

我的建议是设计一个应用程序和映射,使其在索引中不包含类型参数

要知道为什么弹性搜索这样做的原因是一个链接:https : //www.elastic.co/guide/en/elasticsearch/reference/current/removal-of-types.html#_why_are_mapping_types_being_removed