我需要绘制日期直方图以获取特定日期范围内的提交请求。
日期范围是creation_date(字段)的最小日期和expiry_date(字段)的最大值。我必须在这个范围内绘制submission_request。
目前我将min设置为“now-4M”,将max设置为“now”只是为了显示日期直方图,但我需要更改为上述范围。
我的请求如下:
{
"size": 0,
"_source": {
"excludes": []
},
"aggs": {
"3": {
"terms": {
"field": "channel_type.keyword",
"size": 1000,
"order": {
"_count": "desc"
}
},
"aggs": {
"2": {
"date_histogram": {
"field": "submission_time",
"interval": "1w",
"time_zone": "Asia/Kolkata",
"format": "yyyy-MM-dd",
"min_doc_count": 0,
"offset": "+0d",
"extended_bounds": {
"min": "now-4M",
"max": "now-2M"
}
}
}
}
}
},
"stored_fields": [
"*"
],
"script_fields": {
"campDur": {
"script": {
"inline": "(doc['creation_date'].empty)? 0 : (((new Date().getTime() - doc['creation_date'].value.getMillis())*100 / ( doc['expiry_date'].value.getMillis() - doc['creation_date'].value.getMillis())) > 100) ? 100 : ((new Date().getTime() - doc['creation_date'].value.getMillis())*100 / ( doc['expiry_date'].value.getMillis() - doc['creation_date'].value.getMillis()))",
"lang": "painless"
}
},
"indiviualCount": {
"script": {
"inline": "(doc['redemptionLimit'].empty) ? 0 : ((1.0/doc['redemptionLimit'].value) * 100)",
"lang": "painless"
}
}
},
"docvalue_fields": [
"creation_date",
"expiry_date",
"pre_sms_submission_time",
"response_time",
"submission_time",
"voucher_expiry"
],
"query": {
"bool": {
"must": [
{
"match_all": {}
}
],
"filter": [],
"should": [],
"must_not": []
}
}
}
所有需要使范围extended_range最小值和最大值动态。是否有可能使用kibana,弹性搜索?