自由的羽毛 发表于 2024-6-14 21:43:06

Elasticsearch reindex用管道转换类型

es情况



[*]Elasticsearch 7.1x
使用方法



[*]将通过 convert processor 实现
index准备

POST index_src_1/_doc/1
{
"id":"111111",
"author": "zlh"
}
GET index_src_1/_search查询得到字符串id

        "_source" : {
          "id" : "111111",
          "author" : "zlh"
        }
_reindex复制index

POST /_reindex
{
"source": {
    "index": "index_src_1",
    "size": 10
},
"dest": {
    "index": "index_src_2"
}
}
GET index_src_2/_search查询得到字符串id

        "_source" : {
          "id" : "111111",
          "author" : "zlh"
        }
希望将原index index_src_1中id为string类型转为目标index中long类型

运用 convert 创建 pipeline

PUT _ingest/pipeline/zlh-pipeline-id
{
"description": "描述:运用convert创建pipeline,将id字段的内容转换为long",
"processors" : [
    {
      "convert" : {
      "field" : "id",
      "type": "long"
      }
    }
]
}
_reindex复制index

POST /_reindex
{
"source": {
    "index": "index_src_1",
    "size": 10
},
"dest": {
    "index": "index_src_2",
    "pipeline": "zlh-pipeline-id"
}
}
GET index_src_2/_search查询得到long型id

        "_source" : {
          "author" : "zlh",
          "id" : 111111
        }

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
页: [1]
查看完整版本: Elasticsearch reindex用管道转换类型