Bucket script its not working in visualization

http://localhost:5601/app/kibana#/visualize/create?type=table&indexPattern=40de5dd0-d116-11e7-8753-9f799542eb51&_g=(refreshInterval:('$$hashKey':'object:192',display:'5%20seconds',pause:!f,section:1,value:5000),time:(from:now-7d,mode:quick,to:now))&_a=(filters:!(),linked:!f,query:(language:lucene,query:''),uiState:(vis:(params:(sort:(columnIndex:!n,direction:!n)))),vis:(aggs:!((enabled:!t,id:'1',params:(),schema:metric,type:count)),params:(perPage:10,showMeticsAtAllLevels:!f,showPartialRows:!f,showTotal:!f,sort:(columnIndex:!n,direction:!n),totalFunc:sum),title:'New%20Visualization',type:table))

Hi All,

I am creating the dashboard panels.But here i am facing issue is i can't able to using bucket script visualization for calculations.

I have using console DSL Query here I got percentage calculation and after using same query in filter for visualization its not reflecting for table format.

I am using below the query so please tell me how to fix this issue
{
"size": 0,
"query": {
"bool": {
"must": [
{
"match_all": {}
},
{
"range": {
"@timestamp": {
"gte": 1511357255732,
"lte": 1511443655732,
"format": "epoch_millis"
}
}
}
],
"must_not": []
}
},
"_source": {
"excludes": []
},
"aggs": {
"CompanyNumber": {
"terms": {
"field": "msgs.data.ResponseTransaction.Tenant.CompanyNumber",
"size": 5

  },
  "aggs": {
    "DeclineCount": {
      "sum": {
        "script": {
          "inline": "if(doc['msgs.data.ResponseTransaction.Response.ErrorCode'].value == 0){return null}else{return 1}",
          "lang": "painless"
        }
      }
    },
    "TotalCount": {
      "cardinality": {
        "field": "RequestId"
      }
    },
    "Declinepercentage": {
                "bucket_script": {
                    "buckets_path": {
                      "TotalDeclines": "DeclineCount",
                      "TotalTransactions": "TotalCount"
                    },
                    "script": "params.TotalDeclines / params.TotalTransactions * 100"
                }
            }
  }
}

}
}

Thanks.

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