5

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: http://pyelasticsearch.readthedocs.io/en/latest/api/#pyelasticsearch.ElasticSearch.bulk

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/client.py", line 93, in decorate
    return func(*args, query_params=query_params, **kwargs)
  File "/home/fikfok/test_env/lib/python3.5/site-packages/pyelasticsearch/client.py", line 447, in bulk
    query_params=query_params)
  File "/home/fikfok/test_env/lib/python3.5/site-packages/pyelasticsearch/client.py", line 276, in send_request
    body=body)
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)
virtualenv
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!

1
  • Hi, did you manage to solve this issue? Commented Mar 4, 2019 at 10:43

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.