ElasticSearch常见问题2:elasticsearch.exceptions.TransportError:TransportError(406, ‘Content-Type header)

1.问题描述

安装Python3.x版本,使用Python脚本向ElasticSearch中插入数据的时候,出现以下报错信息:

root@scott:/home/scott/work/elasticsearch# python3 es_insertDatabulk.py
POST /_bulk [status:406 request:0.179s]
Traceback (most recent call last):
  File "es_insertDatabulk.py", line 12990, in <module>
    batch_data()  # MemoryError
  File "es_insertDatabulk.py", line 12, in wrapper
    res = func(*args, **kwargs)
  File "es_insertDatabulk.py", line 12987, in batch_data
    helpers.bulk(es, action)
  File "/usr/local/lib/python3.5/dist-packages/elasticsearch/helpers/__init__.py", line 188, in bulk
    for ok, item in streaming_bulk(client, actions, **kwargs):
  File "/usr/local/lib/python3.5/dist-packages/elasticsearch/helpers/__init__.py", line 160, in streaming_bulk
    for result in _process_bulk_chunk(client, bulk_actions, raise_on_exception, raise_on_error, **kwargs):
  File "/usr/local/lib/python3.5/dist-packages/elasticsearch/helpers/__init__.py", line 89, in _process_bulk_chunk
    raise e
  File "/usr/local/lib/python3.5/dist-packages/elasticsearch/helpers/__init__.py", line 85, in _process_bulk_chunk
    resp = client.bulk('\n'.join(bulk_actions) + '\n', **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/elasticsearch/client/utils.py", line 69, in _wrapped
    return func(*args, params=params, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/elasticsearch/client/__init__.py", line 782, in bulk
    doc_type, '_bulk'), params=params, body=self._bulk_body(body))
  File "/usr/local/lib/python3.5/dist-packages/elasticsearch/transport.py", line 307, in perform_request
    status, headers, data = connection.perform_request(method, url, params, body, ignore=ignore, timeout=timeout)
  File "/usr/local/lib/python3.5/dist-packages/elasticsearch/connection/http_urllib3.py", line 93, in perform_request
    self._raise_error(response.status, raw_data)
  File "/usr/local/lib/python3.5/dist-packages/elasticsearch/connection/base.py", line 105, in _raise_error
    raise HTTP_EXCEPTIONS.get(status_code, TransportError)(status_code, error_message, additional_info)
elasticsearch.exceptions.TransportError: TransportError(406, 'Content-Type header [] is not supported')

2.问题原因

Python的版本和ElasticSearch的版本不匹配,需要更新Python中关于ElasticSearch相关的库。

3.解决办法:

pip install -U elasticsearch
或
pip3 install -U elasticsearch

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值