.onField( colorFacetFieldName )
.discrete()
.createFacetingRequest();
FullTextQuery query = createMatchAllQuery( Car.class );
FacetManager facetManager = query.getFacetManager();
facetManager.enableFaceting( colorFacetRequest );
facetManager.enableFaceting( ccsFacetRequest );
assertEquals( "Wrong number of query matches", 50, query.getResultSize() );
assertFacetCounts( facetManager.getFacets( colorFacetName ), new int[] { 12, 12, 12, 12, 2 } );
assertFacetCounts( facetManager.getFacets( ccsFacetName ), new int[] { 17, 16, 16, 1 } );
Facet colorFacet = facetManager.getFacets( colorFacetName ).get( 0 );
facetManager.getFacetGroup( colorFacetName ).selectFacets( colorFacet );
assertFacetCounts( facetManager.getFacets( colorFacetName ), new int[] { 12, 0, 0, 0, 0 } );
assertFacetCounts( facetManager.getFacets( ccsFacetName ), new int[] { 4, 4, 4, 0 } );
Facet ccsFacet = facetManager.getFacets( ccsFacetName ).get( 0 );
facetManager.getFacetGroup( colorFacetName ).selectFacets( colorFacet );
facetManager.getFacetGroup( ccsFacetName ).selectFacets( ccsFacet );
assertFacetCounts( facetManager.getFacets( colorFacetName ), new int[] { 4, 0, 0, 0, 0 } );
assertFacetCounts( facetManager.getFacets( ccsFacetName ), new int[] { 4, 0, 0, 0 } );
assertEquals(
"Facets should not take count in equality",
colorFacet,
facetManager.getFacets( colorFacetName ).get( 0 )
);
assertTrue(
"We should be able to find facets amongst the selected ones",
facetManager.getFacetGroup( colorFacetName ).getSelectedFacets().contains(
facetManager.getFacets( colorFacetName ).get( 0 )
)
);
facetManager.getFacetGroup( colorFacetName ).clearSelectedFacets();
facetManager.getFacetGroup( ccsFacetName ).clearSelectedFacets();
assertFacetCounts( facetManager.getFacets( colorFacetName ), new int[] { 12, 12, 12, 12, 2 } );
assertFacetCounts( facetManager.getFacets( ccsFacetName ), new int[] { 17, 16, 16, 1 } );
}