If you have ever used the field collapsing functionality of Solr you may be wondering if there is a possibility of using that functionality and faceting. Of course there is, but the default behavior still works so that you get the faceting calculation on the basis of documents not document groups. In this recipe, we will learn how to query Solr so that it returns facets calculated for the most relevant document in each group in order for your user facet counts to be more or less grouped.
Before reading this recipe please look at the Using field to group results, Using query to group results, and Using function query to group results recipes in Chapter 8, Using Additional Solr Functionalities. Also, if you are not familiar with faceting functionality, please read the first three recipes in this chapter.