今天要實現一個生日提醒功能,但原來生日存的是時間戮,如:1282014454,對應日期爲:2010-08-17 11:07:34, 單獨判斷生日的時候並不好判斷,現在需要在寫入時間戮的同時把生日部分0817
存入另一個字段,可以通過es提供的pipeline中的script處理器來實現,這個script使用painless語言語法,類似java,具體可參考:https://github.com/elastic/elasticsearch/tree/master/modules/lang-painless
{
"description": "當cno爲空或unionid爲空時移除",
"version":1,
"processors": [
{
"remove": {
"if": "ctx.cno == ''",
"field": "cno"
}
},
{
"remove": {
"if": "ctx.unionid == ''",
"field": "unionid"
}
},
{
"script": {
"if": "ctx.member_birthday > 0",
"lang": "painless",
"source": "def t = LocalDateTime.ofEpochSecond(ctx.member_birthday, 0, ZoneOffset.ofHours(8)); ctx.birthday = t.format( DateTimeFormatter.ofPattern(\"MMdd\"));"
}
}
]
}