I'm trying to find out if it's possible to facet/aggregate on a field, if that field (which is an array) contains 1 or more records.
For example - Let's say I have 3 documents in my index, all under the "user" type.
{
"id": 1,
"name": "Thomas",
"surname": "Test",
"photos": []
},
{
"id": 2,
"name": "Thomas",
"surname": "Test",
"photos": [
"photo 1",
"photo 2",
"photo 3"
]
},
{
"id": 3,
"name": "Thomas",
"surname": "Test",
"photos": [
"photo 1",
"photo 2",
"photo 3"
]
}
I want some kind of way (using aggregations) to return the "number of users who have (or who don't have, seeing as I can just subtract that from the _totalHits) photos in their profile." In this example, the expected result will be 2, seeing as 2 users have photos, or 1, seeing as 1 user doesn't have a photos. Obviously the preferred one I want is the one returning the count of users who have photos.
Is this possible? If so - which type of aggregation would I use to accomplish this?