elasticsearch - 在 Elastic 中使用 _reindex 将字符串字段转换为浮点数
问题描述
使用弹性 7.11.0。
我有一个字段间歇性地保存在索引中:
{
"index_with_string" : {
"mappings" : {
"timeElapsed" : {
"full_name" : "timeElapsed",
"mapping" : {
"timeElapsed" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
}
}
}
}
}
}
我想这样映射:
{
"index_with_float" : {
"mappings" : {
"timeElapsed" : {
"full_name" : "timeElapsed",
"mapping" : {
"timeElapsed" : {
"type" : "float"
}
}
}
}
}
}
我尝试了以下转换管道:
{
"description": "converts the field timeElapsed to a float from a string",
"processors" : [
{
"convert" : {
"field" : "timeElapsed",
"type": "float"
}
}
]
}
但是当我运行 _reindex.
我被要求提供一份文件。这是一个示例,这是来自字段输入正确(作为浮点数)的索引,但来自索引中的错误输入(作为字符串)的文档看起来完全相同。
{
"_index": "xxxx",
"_type": "_doc",
"_id": "jZP2fngBL9sLO82CU7J6",
"_version": 1,
"_score": null,
"_source": {
"tags": [
"beats_input_codec_plain_applied",
"operation"
],
"offset": 8922935,
"className": "MerchantService.GetMerchantOperation",
"@timestamp": "2021-03-29T17:09:34.389Z",
"startTime": "2021-03-29T17:09:34.280Z",
"endTime": "2021-03-29T17:09:34.389Z",
"@version": "1",
"timeElapsed": 0.109
},
"fields": {
"startTime": [
"2021-03-29T17:09:34.280Z"
],
"@timestamp": [
"2021-03-29T17:09:34.389Z"
],
"endTime": [
"2021-03-29T17:09:34.389Z"
]
},
"sort": [
1617037774389
]
}
谁能帮助我正确的转换管道?
谢谢你。