Elasticsearch reindex用管道转换类型

打印 上一主题 下一主题

主题 598|帖子 598|积分 1794

es情况



  • Elasticsearch 7.1x
使用方法



  • 将通过 convert processor 实现
index准备

  1. POST index_src_1/_doc/1
  2. {
  3.   "id":"111111",
  4.   "author": "zlh"
  5. }
复制代码
GET index_src_1/_search查询得到字符串id

  1.         "_source" : {
  2.           "id" : "111111",
  3.           "author" : "zlh"
  4.         }
复制代码
_reindex复制index

  1. POST /_reindex
  2. {
  3.   "source": {
  4.     "index": "index_src_1",
  5.     "size": 10
  6.   },
  7.   "dest": {
  8.     "index": "index_src_2"
  9.   }
  10. }
复制代码
GET index_src_2/_search查询得到字符串id

  1.         "_source" : {
  2.           "id" : "111111",
  3.           "author" : "zlh"
  4.         }
复制代码
希望将原index index_src_1中id为string类型转为目标index中long类型

运用 convert 创建 pipeline

  1. PUT _ingest/pipeline/zlh-pipeline-id
  2. {
  3.   "description": "描述:运用convert创建pipeline,将id字段的内容转换为long",
  4.   "processors" : [
  5.     {
  6.       "convert" : {
  7.         "field" : "id",
  8.         "type": "long"
  9.       }
  10.     }
  11.   ]
  12. }
复制代码
_reindex复制index

  1. POST /_reindex
  2. {
  3.   "source": {
  4.     "index": "index_src_1",
  5.     "size": 10
  6.   },
  7.   "dest": {
  8.     "index": "index_src_2",
  9.     "pipeline": "zlh-pipeline-id"
  10.   }
  11. }
复制代码
GET index_src_2/_search查询得到long型id

  1.         "_source" : {
  2.           "author" : "zlh",
  3.           "id" : 111111
  4.         }
复制代码
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

自由的羽毛

金牌会员
这个人很懒什么都没写!

标签云

快速回复 返回顶部 返回列表