I am using elasticsearch to index my data, which looks (sort of) like this:
[
...
{"Name": "john", "Part": "head", "broken": true},
{"Name": "john", "Part": "shoulders", "broken": false},
{"Name": "john", "Part": "knees", "broken": false},
{"Name": "john", "Part": "toes", "broken": false},
{"Name": "steve", "Part": "head", "broken": false},
{"Name": "steve", "Part": "shoulders", "broken": false},
{"Name": "steve", "Part": "knees", "broken": false},
{"Name": "steve", "Part": "toes", "broken": false}
...
]
Now I want to know the overall status of my people in form of a counter, showing how many are hurt and how many are fine. Here the name serves as a fingerprint and the person is fine, if non of his parts is broken:
People fine: 1
People hurt: 1
I tried using my (limited) knowledge of metrics and bucket aggregations but to no avail. Now I want to know:
Is it even possible using an elastic-search query to get this counter? And if yes, how can I construct such a query?