I have a bunch of documents with the fields username and device_os as follows:
{ "username": "foo", "device_os": "Android", ....},
{ "username": "foo", "device_os": "iOS", ....},
{ "username": "bar", "device_os": "Android", ....},
{ "username": "baz", "device_os": "iOS", ....},
{ "username": "foo", "device_os": "iOS", ....}
I would like to get all distinct device_os by username as follows:
{
"foo": ["Android", "iOS"],
"bar": ["Android"],
"baz": ["iOS"]
}
What is the best way to do something like this in elasticsearch, specifically elasticsearch-py?