I have following query , For the two company ids, I would also like to get the unique rows (unique_internal_plays and unique_external_plays). Is that possible ?
{
"facet":{
"unique_viewers" : "unique(uuid)",
"internal_plays": {
"type": "query",
"q": "company:100"
},
"external_plays": {
"type": "query",
"q": "-company:100"
},
"unique_internal_plays": {
"type": "query",
"q": "company:100"
},
"unique_external_plays": {
"type": "query",
"q": "-company:100"
}
}
}
For any facet in the JSON Facet API you can further divide the given facet into nested facets. If you combine this with a stats facet (an aggregate facet), you can get the unique count for a field in that specific bucket:
"internal_plays": {
"type": "query",
"q": "company:100",
"facet": {
"unique_viewers": "unique(uuid)"
}
}
This will create a nested facet under the facet query, effectively giving you a way to further pivot/run statistics across the set for the matching documents.