As far as I can tell, this is currently not supported. Underneath the hood, unique count is doing a cardinality aggregation, and I don't see an option for filtering: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-cardinality-aggregation.html