Package org.hibernate.search.query.engine.spi

Examples of org.hibernate.search.query.engine.spi.FacetManager


        .onField( indexFieldName )
        .discrete()
        .createFacetingRequest();

    FullTextQuery query = fullTextSession.createFullTextQuery( luceneQuery, Car.class );
    FacetManager facetManager = query.getFacetManager();
    facetManager.enableFaceting( request );
    query.setFirstResult( 0 ).setMaxResults( 1 );
    assertEquals( "Wrong number of query matches", 13, query.getResultSize() );

    List<Facet> facetList = facetManager.getFacets( facetName );
    assertFacetCounts( facetList, new int[] { 5, 4, 4, 0 } );

    facetManager.getFacetGroup( facetName ).selectFacets( facetList.get( 0 ) );
    query.list();
    assertEquals( "Wrong number of query matches", 5, query.getResultSize() );
    List<Facet> newFacetList = facetManager.getFacets( facetName );
    assertFacetCounts( newFacetList, new int[] { 5, 0, 0, 0 } );

    facetManager.getFacetGroup( facetName ).selectFacets( facetList.get( 1 ) );
    query.setMaxResults( Integer.MAX_VALUE );
    assertEquals( "Wrong number of query matches", 9, query.list().size() );
    newFacetList = facetManager.getFacets( facetName );
    assertFacetCounts( newFacetList, new int[] { 5, 4, 0, 0 } );
  }
View Full Code Here


        .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 } );
  }
View Full Code Here

        .from( 1.01 ).to( 1.50 )
        .from( 1.51 ).to( 3.00 )
        .from( 4.00 ).to( 5.00 )
        .createFacetingRequest();
    FullTextQuery query = createMatchAllQuery( Fruit.class );
    FacetManager facetManager = query.getFacetManager();
    facetManager.enableFaceting( rangeRequest );

    assertEquals( "Wrong number of query matches", 10, query.getResultSize() );

    List<Facet> facets = facetManager.getFacets( priceRange );
    assertFacetCounts( facets, new int[] { 5, 3, 2, 0 } );

    facetManager.getFacetGroup( priceRange ).selectFacets( facets.get( 2 ) );

    assertEquals( "Wrong number of query matches", 2, query.list().size() );
    List<Facet> newFacetList = facetManager.getFacets( priceRange );
    assertFacetCounts( newFacetList, new int[] { 2, 0, 0, 0 } );
  }
View Full Code Here

        .discrete()
        .orderedBy( FacetSortOrder.COUNT_ASC )
        .createFacetingRequest();
    TermQuery term = new TermQuery( new Term( "make", "honda" ) );
    FullTextQuery query = fullTextSession.createFullTextQuery( term, Car.class );
    FacetManager facetManager = query.getFacetManager();

    facetManager.enableFaceting( requestDesc );
    facetManager.enableFaceting( requestAsc );

    assertFacetCounts( facetManager.getFacets( descendingOrderedFacet ), new int[] { 5, 4, 4, 0 } );
    assertFacetCounts( facetManager.getFacets( ascendingOrderedFacet ), new int[] { 0, 4, 4, 5 } );

    facetManager.disableFaceting( descendingOrderedFacet );
    assertTrue(
        "descendingOrderedFacet should be disabled", query.getFacetManager().getFacets(
        descendingOrderedFacet
    ).isEmpty()
    );
    assertFacetCounts( facetManager.getFacets( ascendingOrderedFacet ), new int[] { 0, 4, 4, 5 } );

    facetManager.disableFaceting( ascendingOrderedFacet );
    assertTrue(
        "descendingOrderedFacet should be disabled",
        facetManager.getFacets( descendingOrderedFacet ).isEmpty()
    );
    assertTrue(
        "ascendingOrderedFacet should be disabled",
        facetManager.getFacets( ascendingOrderedFacet ).isEmpty()
    );
  }
View Full Code Here

        .from( 0 ).to( 1000 )
        .from( 1001 ).to( 1500 )
        .from( 1501 ).to( 3000 )
        .createFacetingRequest();
    FullTextQuery query = createMatchAllQuery( Cd.class );
    FacetManager facetManager = query.getFacetManager();
    facetManager.enableFaceting( rangeRequest );

    List<Facet> facets = facetManager.getFacets( priceRange );
    assertFacetCounts( facets, new int[] { 5, 3, 2 } );
  }
View Full Code Here

        .onField( indexFieldName )
        .range()
        .below( 1500 )
        .createFacetingRequest();
    FullTextQuery query = createMatchAllQuery( Cd.class );
    FacetManager facetManager = query.getFacetManager();
    facetManager.enableFaceting( rangeRequest );

    List<Facet> facets = facetManager.getFacets( priceRange );
    assertFacetCounts( facets, new int[] { 5 } );
  }
View Full Code Here

        .onField( indexFieldName )
        .range()
        .below( 1500 ).excludeLimit()
        .createFacetingRequest();
    FullTextQuery query = createMatchAllQuery( Cd.class );
    FacetManager facetManager = query.getFacetManager();
    facetManager.enableFaceting( rangeRequest );

    List<Facet> facets = facetManager.getFacets( priceRange );
    assertFacetCounts( facets, new int[] { 2 } );
  }
View Full Code Here

        .onField( indexFieldName )
        .range()
        .above( 1500 )
        .createFacetingRequest();
    FullTextQuery query = createMatchAllQuery( Cd.class );
    FacetManager facetManager = query.getFacetManager();
    facetManager.enableFaceting( rangeRequest );

    List<Facet> facets = facetManager.getFacets( priceRange );
    assertFacetCounts( facets, new int[] { 8 } );
  }
View Full Code Here

        .onField( indexFieldName )
        .range()
        .above( 1500 ).excludeLimit()
        .createFacetingRequest();
    FullTextQuery query = createMatchAllQuery( Cd.class );
    FacetManager facetManager = query.getFacetManager();
    facetManager.enableFaceting( rangeRequest );

    List<Facet> facets = facetManager.getFacets( priceRange );
    assertFacetCounts( facets, new int[] { 5 } );
  }
View Full Code Here

        .range()
        .below( 1500 )
        .above( 1500 ).excludeLimit()
        .createFacetingRequest();
    FullTextQuery query = createMatchAllQuery( Cd.class );
    FacetManager facetManager = query.getFacetManager();
    facetManager.enableFaceting( rangeRequest );

    List<Facet> facets = facetManager.getFacets( priceRange );
    assertFacetCounts( facets, new int[] { 5, 5 } );
  }
View Full Code Here

TOP

Related Classes of org.hibernate.search.query.engine.spi.FacetManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.