gpt4 book ai didi

Python Elasticsearch : BulkIndexError: 'not_x_content_exception' while trying to use helpers. 批量

转载 作者:行者123 更新时间:2023-12-05 06:50:54 28 4
gpt4 key购买 nike

所以我一直在尝试学习 Elasticsearch,但遇到了很多问题。我正在尝试将 csv 文件的前 150 行上传到 Elasticsearch,虽然我可以创建索引,但我无法实际插入 csv 文件。我正在使用 Elasticsearch 7.11 和 Kibana 7.11 以及 Python 3.9 这是我的代码:

es = Elasticsearch([{'host': 'localhost', 'port': 9200}])
file = "information.csv"
read_csv = panda.read_csv(file)
beginning_of_file = read_csv.head(150)

elasticsearch.indices.delete(index='info_data', ignore=[400, 404])
elasticsearch.indices.create(index='info_data', ignore=400)
helpers.bulk(es, beginning_of_file, index='info_data')

然后我得到以下错误:

elasticsearch.helpers.errors.BulkIndexError:
('18 document(s) failed to index.', [{'index': {'_index': 'movie_data', '_type': '_doc', '_id':
'KmwJwncBEtJeL_lPLqQ8', 'status': 400, 'error': {'type': 'mapper_parsing_exception', 'reason':
'failed to parse', 'caused_by': {'type': 'not_x_content_exception', 'reason': 'Compressor detection
can only be called on some xcontent bytes or compressed xcontent bytes'

谁能帮我解决这个错误?

感谢您提供的任何帮助。

最佳答案

您没有传递 ES 接受的正确格式来索引数据,您正在从 csv 文件中读取内容,但没有将其转换为 ES 接受发送的正确格式。

请引用this article了解如何将数据转换为 ES 兼容格式。

关于Python Elasticsearch : BulkIndexError: 'not_x_content_exception' while trying to use helpers. 批量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66298405/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com