当前位置:网站首页>Data cleaning - ingest using es
Data cleaning - ingest using es
2022-07-30 23:14:00 【talen_hx296】
通常es产品里面,数据清洗的logstash,Here use anotheringest做简单的数据处理
Here is the data separated by comma,变成数组
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_blogs
PUT 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"
}
}
}
}
}
The final processed data
{
"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,This degree of freedom is greater,Can handle slightly more complex data
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"
}
}
]
}
边栏推荐
猜你喜欢
Flex布局使用
2022中国物流产业大会暨企业家高峰论坛在杭州举办!
Compressing Deep Graph Neural Networks via Adversarial Knowledge Distillation
Golang go-redis cluster模式下不断创建新连接,效率下降问题解决
A detailed explanation: SRv6 Policy model, calculation and drainage
Excel basic study notes
StoneDB 为何敢称业界唯一开源的 MySQL 原生 HTAP 数据库?
$\text{ARC 145}$
# # yyds dry goods inventory interview will brush TOP101: to determine whether there is a part of the list
VS2017 compile Tars test project
随机推荐
Reverse linked list - in-place inversion method
PS基础学习(一)
ML之shap:基于FIFA 2018 Statistics(2018年俄罗斯世界杯足球赛)球队比赛之星分类预测数据集利用RF随机森林+计算SHAP值单样本力图/依赖关系贡献图可视化实现可解释性之攻略
mysql锁机制
leetcode 406. Queue Reconstruction by Height 根据身高重建队列(中等)
【CTF】buuctf web 详解(持续更新)
Excel基础学习笔记
Detailed operator
mysql中关于存储过程无法实现迁移复制表中数据问题
[MySQL] DQL related operations
“蔚来杯“2022牛客暑期多校训练营4 L.Black Hole 垃圾计算几何
Debezium error series 20: task failed to create new topic. Ensure that the task is authorized to create topics
[MySQL] Related operations on databases and tables in MySQL
语言代码表
"NIO Cup" 2022 Nioke Summer Multi-School Training Camp 2 H.Take the Elevator
MySQL进阶sql性能分析
DFS题单以及模板汇总
"NIO Cup" 2022 Nioke Summer Multi-School Training Camp 4 DHKLN
JS中? ?和??=和?.和 ||的区别
编码与进制