Added value-count aggregations to search query. #6543

Added a test for aggregations.