【问题标题】:Can't create document with doc_type Elasticsearch - Python无法使用 doc_type Elasticsearch 创建文档 - Python
【发布时间】:2022-10-13 17:09:23
【问题描述】:

我是弹性搜索的新手
所以我试图创建一个具有特定“doc_type”的文档,但是当我传入 doc_type 参数时,我收到了这个错误:

elasticsearch.exceptions.RequestError: RequestError(400, '没有找到 uri [/employees/teacher/1] 和方法 [PUT] 的处理程序', '没有找到 uri [/employees/teacher/1] 和方法 [PUT] 的处理程序] ')

有谁知道出了什么问题?
我的代码:

es = Elasticsearch(
    ["localhost"], 
    port=9200, 
    connection_class=RequestsHttpConnection, 
    http_auth=("elastic", "elastic"), 
    use_ssl=True, 
    verify_certs=False
)

body = {
    'name': 'John',
    'age': 21
}

# es.indices.create(index = 'employees')

# This line works fine
es.index(index='employees', id = 1, body = body, refresh = 'true' )

# This line caused the error
es.index(index='employees', doc_type='teacher', id = 1, body = body )

【问题讨论】:

    标签: python elasticsearch


    【解决方案1】:

    映射类型(又名 doc_type)have been deprecated 并且您应该简单地使用 _doc 而不是像在第一个 es.index() 语句中那样指定 doc_type 参数。

    从 8.0.0 版开始,doc_type 甚至是 removed from the available parameters

    【讨论】:

      猜你喜欢
      • 2016-12-07
      • 2018-04-30
      • 1970-01-01
      • 2020-05-04
      • 2021-04-01
      • 2019-11-30
      • 2020-09-05
      • 2021-04-10
      • 1970-01-01
      相关资源
      最近更新 更多