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

标签 python elasticsearch kibana

所以我一直在尝试学习 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/

相关文章:

python - Elasticsearch-DSL嵌套过滤

python - 来自 Python 应用程序的 ElasticSearch/Kibana 中的地理点数据

proxy - Kibana 4 代理仪表板嵌入

python - 如何返回numpy数组中两个数字之间的值索引

python - 获取类中的属性列表

python - 如何在Python的SMBCoonect listPath函数中设置模式匹配

elasticsearch - 无痛脚本Math.max更改我的数据类型

python - 无法在 Ejabberd 19.09.1 中启动外部身份验证程序

Elasticsearch - 仅索引对象的一部分

java - 如何在表格格式的消息中将JSON spring boot日志显示为单独的字段