python-3.x - 如何使用 Python3 解决 Elasticsearch 中的 BUG INTEGER 映射问题?
问题描述
我必须索引一些数据,其中一行具有值:
'c_22': {
'raw': '53095200303310000118800091005',
'integer': 53095200303309998490927497216
},
这是将在 Elasticsearch 中作为文档索引的键值对之一。虽然,Python3 能够将其作为整数,但在 Elasticsearch 中对其进行索引会引发错误:
'error': {
'caused_by': {
'type': 'illegal_state_exception',
'reason': 'No matching token for number_type [BIG_INTEGER]'
},
'type': 'mapper_parsing_exception',
'reason': 'failed to parse'
},
'_index': '8ca178b8cc4dd678147409af92029685',
'_id': 'b4505cd90c5e6c47c38889c5722ff495',
'status': 400
}
注意:上面发布的值是我对这个错误的根本原因的估计。调试器打印出来的完整行在这里
解决方案
我通过以下方式做对了:
if _datatype == "number":
column_parsed_value *= 1.0 #in order to avoid biginteger issue in es.
这是解决 bigint 问题的标准方法;Python 可以,但 ES 不行。
推荐阅读
- python - 有什么方法可以检查 Python Socket 中是否有传入消息
- python - PyCrypto 签名验证与其他语言一起失败
- java - 当我有特定的坐标来检测球和砖块之间的碰撞时,为什么球对象会与不可见的墙壁发生碰撞?
- apache-kafka - zookeeper.session.timeout.ms 是否适用于消费者或代理?
- python - 根据某些条件在python中将连续列转换为二进制
- r - 如何将操作按钮引用到闪亮的插入图(insertUI/removeUI)
- ocaml - Psum 不累积(多态高阶函数)而不强制类型
- php - 如何在 woocommerce wordpress php 中为每个使用相同产品的用户设置不同的价格或折扣?
- reactjs - 如何在创建反应应用程序中排除名为 test.js 的源被检测为测试文件?
- asp.net - ApplicationDbContext 对象