ES 6.7 一些有趣的语句
1、判断 date 类型是不是 null 值,不是 null 值的加 1 天/月年
curl -XGET "vqa132:19200/script_common/_search?&size=0&pretty" -H 'Content-Type: application/json' -d'
{
"aggs": {
"agg_name": {
"date_histogram": {
"script": {
"lang": "painless",
"source": "if (doc[\u0027class\u0027].size()==0){return params.date}else {return doc[\u0027birthday\u0027].value.plusDays(1)}",
"params": {
"date" : 2208960000000
}
},
"interval": "year",
"min_doc_count": 1
}
}
}
}
';