elasticsearch 添加自定义统计字段
elastisearch Scripted fields 自定义字段
1、字段值转换

def hangyes= [243: '橱柜', 244: '卫浴', 32: '地板', 33: '吊顶', 65: '陶瓷', 70: '衣柜', 188: '硅藻泥', 387: '净水器', 477: '木门', 276: '门窗', 393: '集成灶', 478: '晾衣架', 404: '智能家居', 175: '墙纸墙布', 176: '窗帘布艺'];
def key = doc['hangye'].value;
def type = hangyes[key];
return '其他';
2、时间戳转日期

def startDate = doc['addtime'].value;
return startDate * 1000;
日期相关函数
return new SimpleDateFormat('YYYY-MM-dd').format(new Date(startDate * 1000));
return Integer.parseInt(new SimpleDateFormat('YYYYMMdd').format(new Date(startDate * 1000)));

浙公网安备 33010602011771号