我必须索引一些数据,其中一行具有值:
'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/