I think im almost there so hopefully this should be an easy fix, im trying to get a percentage value
Percentage of docs that meet the filtered_docs criteria out of all the docs in the index.
Calculation should be - (total(from filter)/ total)*100
The query im trying to do gets me my values but I don't know how to complete the calculation with a script
GET <index>/_search
{
"aggs": {
"total": { "value_count": { "field": "_id" } },
"filtered": {
"filter": {
"bool": {
"must": [
{
"wildcard": {
"field1": {
"value": "*<string>*"
}
}
},
{
"range": {
"field2": {
"lt": "now-30d/d"
}
}
}
],
"must_not": {
"range": {
"field3": {
"gt": "now"
}
}
}
}
},
"aggs": {
"total": {
"value_count": { "field": "_id" }
}
}
}
}
}
I get the below result which is correct but I want to use a script of some kind in this aggregation to do (params.filtered.total / params.total) * 100
"aggregations" : {
"total" : {
"value" : 200
},
"filtered_docs" : {
"meta" : { },
"doc_count" : 20,
"total" : {
"value" : 20
}
}
}
Happy to clarify any questions