Hello,
I want to calculte the percent of a given type on my index: Ok_Count/total , I wrote this query
But it doesn't work as i excepted , could you help me to correct it
{
"aggs": {
"total":{
"filter": {
"bool": {
"should": [{
"term": {"FieldPresentOnAllDocument": "F"}
}]
}
}
},
"OK": {
"filter": {
"bool": {
"must": {
"bool": {
"should": [
{
"bool": {
"must": {
"range": {
"MyField": {
"gte": 100,
"lte": 399
}
}
}
}
},
{
"bool": {
"should": [
{
"term": {"MyField": "0"}
},
{
"term": {"MyField": "5"}
},
{
"term": {"MyField": "6"}
}
]
}
}
]
}
}
}
}
}
},
"size":0
}
result is :
{
"took" : 1101,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 10000,
"relation" : "gte"
},
"max_score" : null,
"hits" : [ ]
},
"aggregations" : {
"Ok" : {
"doc_count" : 5342374
},
"total" : {
"MyField" : 0
}
}
}