Upload data via python bulk helper caused error

Cluster ID: f0a801

Hello,

We are trying to push data to dynamically created indices. Using python helper (http://elasticsearch-py.readthedocs.org/en/master/helpers.html), we tried to upload data in two following formats:

Format 1: {command n}, {data n}, {command n+1}, {data n+1}, i.e.,
{"create":{"_index":"current_index","_type":"prod"}}, {json.dumps(X)}

Format 2:
{"_op_type":"create","_index":"current_index","_type":"prod","_source": json.dumps(X)}

Iterable variables have been created out of above data and fed into helpers.bulk

However, in any case the following error is appearing:

  File "/usr/local/lib/python2.7/json/__init__.py", line 251, in dumps
    sort_keys=sort_keys, **kw).encode(obj)
  File "/usr/local/lib/python2.7/json/encoder.py", line 207, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/usr/local/lib/python2.7/json/encoder.py", line 270, in iterencode
    return _iterencode(o, 0)
  File "/usr/local/lib/python2.7/json/encoder.py", line 184, in default
    raise TypeError(repr(o) + " is not JSON serializable")

TypeError: RequestError(400, u'action_request_validation_exception', {u'status': 400, u'error': {u'root_cause': [{u'reason': u'Validation Failed: 1:index is missing;2: type is missing; u'type': u'action_request_validation_exception'}

Please evaluate.

Thank you,

1 Like

I've moved this topic to the Elasticsearch forum, as it seems to be a language client-specific usage question.

How did you solve this? I have the same issue with Python and elasticsearch 5.1.1