我有一个JSON文件,我正在加载它json.load文件方法,然后将内容发送到Elasticsearch。但是,它抛出了一个错误。你知道吗
示例代码:
inputFile = sys.argv[1]
with open(inputFile) as jsonFile:
jsonData = json.load(jsonFile)
es = Elasticsearch([{'host':'x.x.x.175', 'port':9200}])
es.index(index="fmb_420", doc_type='fmb_420', body=jsonData)
日志错误:
Traceback (most recent call last):
File "FMB_DB.py", line 12, in <module>
es.index(index="fmb_420", doc_type='fmb_420', body=jsonData)
File "/usr/lib/python2.7/site-packages/elasticsearch/client/utils.py", line 76, in _wrapped
return func(*args, params=params, **kwargs)
File "/usr/lib/python2.7/site-packages/elasticsearch/client/__init__.py", line 319, in index
_make_path(index, doc_type, id), params=params, body=body)
File "/usr/lib/python2.7/site-packages/elasticsearch/transport.py", line 314, in perform_request
status, headers_response, data = connection.perform_request(method, url, params, body, headers=headers, ignore=ignore, timeout=timeout)
File "/usr/lib/python2.7/site-packages/elasticsearch/connection/http_urllib3.py", line 180, in perform_request
self._raise_error(response.status, raw_data)
File "/usr/lib/python2.7/site-packages/elasticsearch/connection/base.py", line 125, in _raise_error
raise HTTP_EXCEPTIONS.get(status_code, TransportError)(status_code, error_message, additional_info)
elasticsearch.exceptions.RequestError: TransportError(400, u'mapper_parsing_exception', u'not_x_content_exception: Compressor detection can only be called on some xcontent bytes or compressed xcontent bytes')
更新:
在JSON没有根元素之前,我通过在JSON文件中添加根元素修复了这个问题。你知道吗
我通过在JSON文件中添加根元素解决了这个问题。你知道吗
例如从这个到
这个:
相关问题 更多 >
编程相关推荐