python-3.x - 如何使用Python3解决Elasticsearch中的BUG INTEGER映射问题?

标签 python-3.x elasticsearch

我必须索引一些数据,其中一行具有值:

'c_22': {
            'raw': '53095200303310000118800091005',
            'integer': 53095200303309998490927497216
        },

这是在Elasticsearch中将被索引为doc的键值对之一。虽然,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
}

注意:上面发布的值是我对该错误的根本原因的估计。调试器打印出的完整行是here

最佳答案

我通过以下方式正确了:

if _datatype == "number":
   column_parsed_value *= 1.0 #in order to avoid biginteger issue in es.

这是解决bigint问题的标准方法。 Python会没事的,但ES不会。

关于python-3.x - 如何使用Python3解决Elasticsearch中的BUG INTEGER映射问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53801184/

相关文章:

elasticsearch - 最有用的 ElasticSearch 插件

python - 如何在Python中构建创建表脚本

python - 是否可以求解欠定线性方程组? (最好使用 SymPy)

elasticsearch - 根据elasticsearch中选定的类型增强结果

ruby-on-rails - Elasticsearch 无法以索引开头且别名需要唯一错误

elasticsearch - 为什么在Elasticsearch中存在映射?

python - 不会为自定义用户模型保存配置文件数据

python - + : int and str in a while loop 不受支持的操作数类型

python-3.x - 访问使用 webdav 客户端 python 加密的 nextcloud SSL 时出现问题

elasticsearch - Kibana发现:搜索特殊字符: '@'