Package org.hibernate.search

Examples of org.hibernate.search.FullTextQuery


    FacetingRequest request = queryBuilder( Car.class ).facet()
        .name( facetName )
        .onField( indexFieldName )
        .discrete()
        .createFacetingRequest();
    FullTextQuery query = queryHondaWithFacet( request );

    List<Facet> facetList = query.getFacetManager().getFacets( facetName );
    assertFacetCounts( facetList, new int[] { 5, 4, 4, 0 } );
  }
View Full Code Here


        .name( facetName )
        .onField( indexFieldName )
        .discrete()
        .orderedBy( FacetSortOrder.COUNT_ASC )
        .createFacetingRequest();
    FullTextQuery query = queryHondaWithFacet( request );

    List<Facet> facetList = query.getFacetManager().getFacets( facetName );
    assertFacetCounts( facetList, new int[] { 0, 4, 4, 5 } );
  }
View Full Code Here

        .name( facetName )
        .onField( indexFieldName )
        .discrete()
        .orderedBy( FacetSortOrder.COUNT_DESC )
        .createFacetingRequest();
    FullTextQuery query = queryHondaWithFacet( request );

    List<Facet> facetList = query.getFacetManager().getFacets( facetName );
    assertFacetCounts( facetList, new int[] { 5, 4, 4, 0 } );
  }
View Full Code Here

        .name( facetName )
        .onField( indexFieldName )
        .discrete()
        .orderedBy( FacetSortOrder.FIELD_VALUE )
        .createFacetingRequest();
    FullTextQuery query = queryHondaWithFacet( request );

    List<Facet> facetList = query.getFacetManager().getFacets( facetName );
    for ( int i = 1; i < facetList.size() - 1; i++ ) {
      String previousFacetValue = facetList.get( i - 1 ).getValue();
      String currentFacetValue = facetList.get( i ).getValue();
      assertTrue( "Wrong alphabetical sort order", previousFacetValue.compareTo( currentFacetValue ) < 0 );
    }
View Full Code Here

        .onField( indexFieldName )
        .discrete()
        .orderedBy( FacetSortOrder.COUNT_DESC )
        .includeZeroCounts( false )
        .createFacetingRequest();
    FullTextQuery query = queryHondaWithFacet( request );

    List<Facet> facetList = query.getFacetManager().getFacets( facetName );
    assertFacetCounts( facetList, new int[] { 5, 4, 4 } );
  }
View Full Code Here

        .onField( indexFieldName )
        .discrete()
        .orderedBy( FacetSortOrder.COUNT_DESC )
        .maxFacetCount( 1 )
        .createFacetingRequest();
    FullTextQuery query = queryHondaWithFacet( request );

    List<Facet> facetList = query.getFacetManager().getFacets( facetName );
    assertEquals( "The number of facets should be restricted", 1, facetList.size() );
    assertFacetCounts( facetList, new int[] { 5 } );
  }
View Full Code Here

    FacetingRequest request = queryBuilder( Car.class ).facet()
        .name( "foo" )
        .onField( "foobar" )
        .discrete()
        .createFacetingRequest();
    FullTextQuery query = queryHondaWithFacet( request );

    List<Facet> facetList = query.getFacetManager().getFacets( facetName );
    assertTrue( facetList.isEmpty() );
  }
View Full Code Here

    FacetingRequest request = queryBuilder( Car.class ).facet()
        .name( facetName )
        .onField( indexFieldName )
        .discrete()
        .createFacetingRequest();
    FullTextQuery query = queryHondaWithFacet( request );

    assertTrue( "We should have facet results", query.getFacetManager().getFacets( facetName ).size() > 0 );

    query.getFacetManager().disableFaceting( facetName );
    query.list();

    assertTrue( "We should have no facets", query.getFacetManager().getFacets( facetName ).size() == 0 );
  }
View Full Code Here

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

    );
  }

  private FullTextQuery queryHondaWithFacet(FacetingRequest request) {
    Query luceneQuery = queryBuilder( Car.class ).keyword().onField( "make" ).matching( "Honda" ).createQuery();
    FullTextQuery query = fullTextSession.createFullTextQuery( luceneQuery, Car.class );
    query.getFacetManager().enableFaceting( request );
    assertEquals( "Wrong number of query matches", 13, query.getResultSize() );
    return query;
  }
View Full Code Here

TOP

Related Classes of org.hibernate.search.FullTextQuery

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.