@Test
public void testFacetEmbeddedAndCollections() throws Exception {
FullTextSession fullTextSession = Search.getFullTextSession( openSession() );
FullTextQuery fullTextQuery = fullTextSession.createFullTextQuery( new MatchAllDocsQuery(), Book.class );
QueryBuilder builder = fullTextSession.getSearchFactory().buildQueryBuilder().forEntity( Book.class ).get();
FacetingRequest facetReq = builder.facet()
.name( "someFacet" )
.onField( "authors.name_untokenized" )
.discrete()
.orderedBy( FacetSortOrder.COUNT_DESC )
.includeZeroCounts( false ).maxFacetCount( 10 )
.createFacetingRequest();
List<Facet> facets = fullTextQuery.getFacetManager().enableFaceting( facetReq ).getFacets( "someFacet" );
assertEquals( "There should be three facets", 3, facets.size() );
assertFacet( facets.get( 0 ), hugo, 3 );
assertFacet( facets.get( 1 ), moliere, 2 );
assertFacet( facets.get( 2 ), voltaire, 1 );