问题现象:

写入时单条或一批次的总数据大小超过es限制就会报 TransportError(413, '')

解决:

修改es配置文件 elasticsearch.yml增加max_content_length,具体大小看实际环境需求,越大性能越差

http.max_content_length: 1024mb

File "/opt/python3.8/site-packages/elasticsearch/helpers/actions.py", line 300, in bulk
    for ok, item in streaming_bulk(client, actions, *args, **kwargs):
  File "/opt/python3.8/site-packages/elasticsearch/helpers/actions.py", line 221, in streaming_bulk
    for data, (ok, info) in zip(
  File "/opt/python3.8/site-packages/elasticsearch/helpers/actions.py", line 116, in _process_bulk_chunk
    raise e
  File "/opt/python3.8/site-packages/elasticsearch/helpers/actions.py", line 112, in _process_bulk_chunk
    resp = client.bulk("\n".join(bulk_actions) + "\n", *args, **kwargs)
  File "/opt/python3.8/site-packages/elasticsearch/client/utils.py", line 84, in _wrapped
    return func(*args, params=params, **kwargs)
  File "/opt/python3.8/site-packages/elasticsearch/client/__init__.py", line 1484, in bulk
    return self.transport.perform_request(
  File "/opt/python3.8/site-packages/elasticsearch/transport.py", line 351, in perform_request
    status, headers_response, data = connection.perform_request(
  File "/opt/python3.8/site-packages/elasticsearch/connection/http_urllib3.py", line 257, in perform_request
    self._raise_error(response.status, raw_data)
  File "/opt/python3.8/site-packages/elasticsearch/connection/base.py", line 181, in _raise_error
    raise HTTP_EXCEPTIONS.get(status_code, TransportError)(
elasticsearch.exceptions.TransportError: TransportError(413, '')