{"name": "John", "district": 1, "light": 2},
{"name": "John", "district": 5, "light": 2},
{"name": "John", "district": 5, "light": 27},
{"name": "John", "district": 11, "light": 1},
{"name": "John", "district": 11, "light": 0},
{"name": "John", "district": 11, "light": 10},
{"name": "John", "district": 8, "light": 6},
{"name": "Mary", "district": 2, "light": 10},
{"name": "Nick", "district": 1, "light": 0},
{"name": "Bob", "district": 3, "light": 10},
{"name": "Kenny", "district": 1, "light": 8}
When searching by name field, how can i get a summary of the remaining fields by group count?
Example:
When searching by
"query": {
"term": {
"name": {
"value": "john"
}
}
}
Expected output:
{
"district": {
11: 3, // value : the amount of matches
5: 2,
1: 1,
},
"light": {
2: 2, // value : the amount of matches
27: 1,
10: 1,
// etc..
}
}