AttributeError: 'HTTPHeaderDict' object has no attribute 'get_all' while mapping the mappings in elasticsearch

Viewed 1504

Here I have added my code:


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()

Here I am adding my elasticsearch and elasticsearch_dsl versions:

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

The error I have got from the code:

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

Please help me!

1 Answers

For me it got fixed by upgrading urllib3 lib.

The elasticsearch lib was upgraded from 6.x to 7.x some days ago and urllib3 version was 1.24.1.

An upgrade to 1.25.10 fixed it.

Related