Visalization with aggregate and bucket_script

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;
							"""
            }
          }
        }
      }
    }
  }
}

Bucket script is currently not supported in Kibana: https://github.com/elastic/kibana/issues/4707

You can use the Vega visualization as an escape hatch (it's possible to freely specify your query there), but that means you would need to specify your chart using Vega as well.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.