通常es产品里面,数据清洗的logstash,这里使用另外的ingest做简单的数据处理

这里是根据逗号分隔数据,变成数组

PUT spring_blogs/_doc/1
{"title":"Introducing spring framework......","tags":"spring,spring boot,spring cloud","content":"You konw, for spring framework"
}POST _ingest/pipeline/_simulate
{"pipeline": {"description": "to split blog tags","processors": [{"split": {"field": "tags","separator": ","}}]},"docs": [{"_index": "index","_id": "id","_source": {"title": "Introducing spring framework......","tags": "spring,spring boot,spring cloud","content": "You konw, for spring framework"}},{"_index": "index","_id": "idxx","_source": {"title": "Introducing cloud computering","tags": "docker,k8s,ingrest","content": "You konw, for cloud"}}]
}
# 为ES添加一个 Pipeline
PUT _ingest/pipeline/spring_blog_pipeline
{"description": "a spring blog pipeline","processors": [{"split": {"field": "tags","separator": ","}},{"set":{"field": "views","value": 0}}]
}#查看Pipleline
GET _ingest/pipeline/spring_blog_pipeline#测试pipeline
POST _ingest/pipeline/spring_blog_pipeline/_simulate
{"docs": [{"_source": {"title": "Introducing cloud computering","tags": "docker,k8s,ingrest","content": "You konw, for cloud"}}]
}DELETE spring_blogsPUT spring_blogs/_doc/1
{"title":"Introducing spring framework......","tags":"spring,spring boot,spring cloud","content":"You konw, for spring framework"
}#使用pipeline更新数据
PUT spring_blogs/_doc/2?pipeline=spring_blog_pipeline
{"title": "Introducing cloud computering","tags": "docker,k8s,ingrest","content": "You konw, for cloud"
}POST spring_blogs/_search#增加update_by_query的条件
POST spring_blogs/_update_by_query?pipeline=spring_blog_pipeline
{"query": {"bool": {"must_not": {"exists": {"field": "views"}}}}
}

最终处理后的数据

{"took" : 0,"timed_out" : false,"_shards" : {"total" : 1,"successful" : 1,"skipped" : 0,"failed" : 0},"hits" : {"total" : {"value" : 2,"relation" : "eq"},"max_score" : 1.0,"hits" : [{"_index" : "spring_blogs","_id" : "2","_score" : 1.0,"_source" : {"title" : "Introducing cloud computering","content" : "You konw, for cloud","views" : 0,"tags" : ["docker","k8s","ingrest"]}},{"_index" : "spring_blogs","_id" : "1","_score" : 1.0,"_source" : {"title" : "Introducing spring framework......","content" : "You konw, for spring framework","views" : 0,"tags" : ["spring","spring boot","spring cloud"]}}]}
}

还可以使用Script Prcessor,这种自由度更大,可以处理稍微复杂点数据

POST _ingest/pipeline/_simulate
{"pipeline": {"description": "to split spring blog tags","processors": [{"split": {"field": "tags","separator": ","}},{"script": {"source": """if(ctx.containsKey("title")){ctx.content_length = ctx.title.length();}else{ctx.content_length=0;}"""}},{"set": {"field": "views","value": 0}}]},"docs": [{"_index": "index","_id": "id","_source": {"title": "Introducing spring framework......","tags": "spring,spring boot,spring cloud","content": "You konw, for spring framework"}},{"_index": "index","_id": "idxx","_source": {"title": "Introducing cloud computering","tags": "docker,k8s,ingrest","content": "You konw, for cloud"}}]
}

数据清洗-使用es的ingest相关推荐

  1. filebeat收集日志到elsticsearch中并使用ingest node的pipeline处理

    filebeat收集日志到elsticsearch中 一.需求 二.实现 1.filebeat.yml 配置文件的编写 2.创建自定义的索引模板 3.加密连接到es用户的密码 1.创建keystore ...

  2. Elasticsearch调优实践

      背景 Elasticsearch(ES)作为NOSQL+搜索引擎的有机结合体,不仅有近实时的查询能力,还具有强大的聚合分析能力.因此在全文检索.日志分析.监控系统.数据分析等领域ES均有广泛应用. ...

  3. spark配置elasticsearch属性汇总(基于es7)

    必要设置 es.resource Elasticsearch资源位置,在该位置读取和写入数据.需要格式 <index>/<type> es.resource.read(默认为e ...

  4. 【Elasticsearch】es Ingest 节点

    1.概述 1.1 问题引出 来自星球同学的提问: "Ingest node什么场景会遇到它? 一直没搜到它是在什么场景工作的?" 的确我们比较关心集群的节点角色的划分.包括: 集群 ...

  5. ES 检索 word、pdf 文档插件 ingest attachment 的管道配置和文档结构映射

    一.安装 ingest attachment 插件 安装方法:https://blog.csdn.net/catoop/article/details/124468788 二.定义文本抽取管道 1.单 ...

  6. data es集群master_Kubernetes Helm3 部署 ElasticSearch amp; Kibana 7 集群

    一.简介 Elasticsearch 是一个分布式的搜索和分析引擎,可以用于全文检索.结构化检索和分析,并能将这三者结合起来.设计用于云计算中,能够达到实时搜索,稳定,可靠,快速,安装使用方便,轻松扩 ...

  7. linux下载python的es库,Elasticsearch py客户端库安装及使用方法解析

    一.介绍 elasticsearch-py是一个官方提供的low-level的elasticsearch python客户端库.为什么说它是一个low-level的客户端库呢?因为它只是对elasti ...

  8. 自建ES迁移至阿里云ES(使用脚本及logstash同步)

    搭建测试3节点ES集群,官网下载所需的版本进行解压运行,ECS与阿里云ES在同一地域可用区,并在相同的VPC内. # mkdir /usr/java # tar xvf jdk-8u162-linux ...

  9. centos7 如何安装部署k8s_五步教你如何使用k8s快速部署ES

    前言 今天小编打算用五步教大家如何使用k8s快速部署ES,有兴趣的小伙伴可以了解一下~ 由于是使用本地存储,所以需要先创建pv 1.创建存储类 local-elasticsearch.yaml kin ...

最新文章

  1. 用数学范畴定义生命的尝试
  2. html不支持png%3e,关于Adobe Flash CS3无法导入png格式图片的修复方法(真正解决问题)...
  3. Android 5.0中的FDE功能实现
  4. WCF技术剖析之五:利用ASP.NET兼容模式创建支持会话(Session)的WCF服务
  5. android webView的使用
  6. cemtos7上mysql8两个实例_centos7上配置mysql8的双主互写
  7. 【资源】斯坦福李飞飞高徒Johnson博士论文: 组成式计算机视觉智能(附195页PDF)
  8. 视觉SLAM笔记(13) 空间变换
  9. pytorch torch.ones
  10. charles抓手机app的包的操作步骤
  11. Ckeditor 的加载顺序
  12. 酷Q自动升级失败的可能解决方法
  13. Scroller的使用
  14. 小学教师评职称计算机考试题,中小学美术教师职称晋升招聘考试题库(含答案)1...
  15. 【前端应该掌握的一些知识点】
  16. 微信小程序中时间戳和日期的相互转换
  17. 【分享】Xmind会默认安装在C盘,如何将Xmind安装在指定文件夹
  18. 【sql注入】二次注入
  19. 【调剂经验】19年一战东南大学计算机专硕调剂蒙纳士,初复试经验调剂经验分享!...
  20. Halcon 3D 常见算子描述

热门文章

  1. PDF转换Word、Excel、PPT、图片,PDF去水印,PDF拆分该怎么做到这些
  2. 网易16年研发实习生笔试题 - 寻找第K大
  3. 操作系统实验三:主存空间的分配与回收
  4. 12-16 云计算平台基础架构
  5. ddos攻击怎么防?防御ddos的几种方法
  6. 把服务器sql数据库导出excel文件,将mysql数据库数据以Excel文件的形式导出
  7. 七:Shell脚本:正则表达式与文本处理器三剑客grep,egrep, sed,awk
  8. 项目配置不当引发了数据泄露,人已裂开!!(建议收藏)
  9. Tampermonkey谷歌浏览器插件
  10. 惹某人突然不舍de第七周(习题+感悟)