elasticsearch之pipeline
·
一,测试pipeline,按逗号拆分字符串为数组,然后对数组的每个项去空格。
POST _ingest/pipeline/_simulate
{
"pipeline" :
{
"description": "_description",
"processors": [
{
"set" : {
"field" : "field2",
"value" : "_value"
}
},
{
"split": {
"field": "words",
"separator": ","
}
},
{
"foreach" : {
"field" : "words",
"processor" : {
"trim": {
"field" : "_ingest._value"
}
}
}
}
]
},
"docs": [
{
"_index": "index",
"_id": "id",
"_source": {
"foo": " bar ",
"words":"hello , world , hello2 hadoop "
}
},
{
"_index": "index",
"_id": "id",
"_source": {
"foo": "rab",
"words":"hello, world , hello2 , flink "
}
}
]
}
二,设置pipeline
PUT _ingest/pipeline/split_and_trim
{
"description" : "describe pipeline",
"processors": [
{
"set" : {
"field" : "field2",
"value" : "_value"
}
},
{
"split": {
"field": "words",
"separator": ","
}
},
{
"foreach" : {
"field" : "words",
"processor" : {
"trim": {
"field" : "_ingest._value"
}
}
}
}
]
}
三,创建index时设置pipeline
PUT twitter
{
"settings" : {
"index" : {
"number_of_shards" : 3,
"number_of_replicas" : 2 ,
"default_pipeline": "split_and_trim"
}
}
}
四,更新时指定pipeline
POST twitter2/_update_by_query?pipeline=split_and_trim
五,索引文档时指定pipeline
PUT twitter2/_doc/2?pipeline=split_and_trim
{
"words":"hadoop222222, good , flink , spark "
}
更多推荐
所有评论(0)