Skip to content

Instantly share code, notes, and snippets.

@hferentschik
Created March 10, 2011 17:18
Show Gist options
  • Save hferentschik/864487 to your computer and use it in GitHub Desktop.
Save hferentschik/864487 to your computer and use it in GitHub Desktop.
public void testFacetDrillDown() throws Exception {
Query luceneQuery = builder.keyword().onField( "make" ).matching( "Honda" ).createQuery();
FacetRequest request = builder.facet()
.name( facetName )
.onField( indexFieldName )
.createFacet();
FullTextQuery query = fullTextSession.createFullTextQuery( luceneQuery, Car.class );
query.enableFacet( request );
assertEquals( "Wrong number of query matches", 13, query.list().size() );
List<Facet> facetList = assertAndReturnFacetList( query );
assertFacetCounts( facetList, new int[] { 5, 4, 4, 0 } );
Filter facetFilter = facetList.get( 0 ).getFacetFilter();
query.setFilter( facetFilter );
assertEquals( "Wrong number of query matches", 5, query.list().size() );
List<Facet> newFacetList = assertAndReturnFacetList( query );
assertFacetCounts( newFacetList, new int[] { 5, 0, 0, 0 } );
facetFilter = facetList.get( 1 ).getFacetFilter();
query.setFilter( facetFilter );
assertEquals( "Wrong number of query matches", 4, query.list().size() );
newFacetList = assertAndReturnFacetList( query );
assertFacetCounts( newFacetList, new int[] { 4, 0, 0, 0 } );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment