pyelasticsearch bulk ValueError: too many values to unpack (expected 2)


December 2018


220 time


I'm new in Python and Elasticsearch. I'm trying to write code to insert documents in Elassticsearch using bulk. It is based on this description:

My code:

>>> from pyelasticsearch import ElasticSearch
>>> es = ElasticSearch()
>>> es.bulk([es.index_op(doc={'id': 1, 'color': 'red'}), es.index_op(doc={'id': 2, 'color': 'green'})], doc_type='test10', index='test10')

Python returns this error message:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/fikfok/test_env/lib/python3.5/site-packages/pyelasticsearch/", line 93, in decorate
    return func(*args, query_params=query_params, **kwargs)
  File "/home/fikfok/test_env/lib/python3.5/site-packages/pyelasticsearch/", line 447, in bulk
  File "/home/fikfok/test_env/lib/python3.5/site-packages/pyelasticsearch/", line 276, in send_request
ValueError: too many values to unpack (expected 2)

But it inserts these documents into Elasticsearch.

What I use:

Linux Mint 18.1
Elasticsearch 5.5.0 (engine)
Python 3.5.2
pyelasticsearch 1.4
elasticsearch 5.4.0 (package in virtual env "test_env")

Please tell me where I'm wrong and how to fix the error. Thanks!

0 answers