AttributeError: module 'elasticsearch' has no attribute 'helpers'
Asked Answered
H

1

7

I can't access the helpers of elasticsearch while trying to push data in bulk mode. Package installed :

pip freeze
elasticsearch==5.3.0

When in my code I try to call this method :

import elasticsearch

 client = elasticsearch.Elasticsearch([config['ES']['host']],
              connection_class=elasticsearch.RequestsHttpConnection,
              http_auth=(config['ES']['userName'], config['ES']['password']),
              port=int(config['ES']['hostPort']),
              use_ssl=True,
              verify_certs=False)
 elasticsearch.helpers.bulk(client, body)

I got the following error :

AttributeError: module 'elasticsearch' has no attribute 'helpers'

I'm using Python 3.5.1 and I have no problem reading data from my es cluster (without the use of helpers of course)

Hatch answered 9/5, 2017 at 13:24 Comment(3)
You need to do import elasticsearch.helpers as that's the way it's setupCombings
I'm so stupid... thx mate :)Hatch
@JonClements how about adding this as an answer? It just helped me and I miss my upvote!Disorganize
M
0

As @Jon Clements♦ correctly said,

import elasticsearch.helpers

Is the correct way to import (therefore also the following works)

from elasticsearch.helpers import scan

Enjoy

Mastoid answered 16/11, 2021 at 16:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.