I'm trying to create a visualization based on the number of days between createdAt and publishedAt. I'm struggling to add the aggregation based on a bucket_script to Kibana's visualization tab. How do I do it?
Below is my query
GET /events-jobs-create/_search
{
"size": 0,
"aggs": {
"company": {
"terms": {
"field": "dimensions.company._id.keyword",
"size": 10
},
"aggs": {
"first_job_create": {
"min": {
"field": "createdAt"
}
},
"first_com_create": {
"max": {
"field": "publishedAt"
}
},
"time_first_job": {
"bucket_script": {
"buckets_path": {
"fjc": "first_job_create",
"fcc": "first_com_create"
},
"script": {
"source": """
double start = 0;
double end = 0;
if(params['fjc'] != null)
{
start = params.fjc;
}
if(params['fcc'] != null)
{
end = params.fcc;
}
return (end-start)/1000.0/86400.0;
"""
}
}
}
}
}
}
}