AttributeError: 'HTTPHeaderDict' 对象在 elasticsearch 中映射映射时没有属性 'get_all'

Tar*_*han 4 python elasticsearch

在这里,我添加了我的代码:


from datetime import datetime
from elasticsearch_dsl import Document, Date, Integer, Keyword, Text
from elasticsearch_dsl.connections import connections

# Define a default Elasticsearch client
connections.create_connection(hosts=['localhost'])

class Article(Document):
    title = Text(analyzer='snowball', fields={'raw': Keyword()})
    body = Text(analyzer='snowball')
    tags = Keyword()
    published_from = Date()
    lines = Integer()

    class Index:
        name = 'blog'
        settings = {
          "number_of_shards": 2,
        }

    def save(self, ** kwargs):
        self.lines = len(self.body.split())
        return super(Article, self).save(** kwargs)

    def is_published(self):
        return datetime.now() >= self.published_from

# create the mappings in elasticsearch
Article.init()
Run Code Online (Sandbox Code Playgroud)

在这里,我添加了我的elasticsearchelasticsearch_dsl 版本:

  1. elasticsearch==7.8.0
  2. elasticsearch_dsl==7.0.0

我从代码中得到的错误:

AttributeError: 'HTTPHeaderDict' object has no attribute 'get_all'

Run Code Online (Sandbox Code Playgroud)

请帮我!

Fed*_*ika 5

对我来说,它通过升级urllib3 lib得到了修复。

elasticsearch LIB从6.x的升级到7.x前几天和urllib3版本是1.24.1。

升级到 1.25.10 修复了它。