I have an index exams
which contains data related to students who passed some exams.
A student can attempt an exam multiple times. Hence there may be more than one document in the index for a particular student and exam, with a different passedOn
date.
I want to create a Kibana Visualization of the count of unique exam completions, ignoring the duplicate values of student
-exam
pair.
The following query gives the latest date of passing each exam
by each student
:
GET exams/_search
{
"size": 0,
"_source": false,
"aggs": {
"student": {
"terms": {
"field": "studentId",
"size": 20000
},
"aggs": {
"exam": {
"terms": {
"field": "examId",
"size": 1000
},
"aggs": {
"latest": {
"max": {
"field": "passedOn"
}
}
}
}
}
}
}
}
How can I visualize the unique count of student
-exam
pair, either using the latest passedOn
date or using runtime fields
or scripted fields
or some other way?