Package org.hibernate.search

Examples of org.hibernate.search.FullTextQuery


        .from( 0.00 ).to( 1.00 )
        .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


  public void assertFindsByRoadName(String analyzedRoadname) {
    FullTextSession fullTextSession = Search.getFullTextSession( openSession() );
    resetFieldSelector();
    Transaction tx = fullTextSession.beginTransaction();
    TermQuery ftQuery = new TermQuery( new Term( "stops.roadName", analyzedRoadname ) );
    FullTextQuery query = fullTextSession.createFullTextQuery( ftQuery, BusLine.class );
    query.setProjection( "busLineName" );
    assertEquals( 1, query.list().size() );
    List results = query.list();
    try {
      assertFieldSelectorEnabled( "busLineName" );
    }
    catch (IOException e) {
      fail( "unexpected exception " + e );
View Full Code Here

      name = "testSetLookupMethodPersistenceContext")
  public void testDefaultLookupMethod() throws Exception {
    try ( FullTextSessionBuilder builder = buildFullTextSessionBuilder( null, null ) ) {
      indexTestData( builder );
      FullTextSession fullTextSession = builder.openFullTextSession();
      FullTextQuery query = fullTextSession.createFullTextQuery( new MatchAllDocsQuery() );
      query.list();
      fullTextSession.close();

      Assert.assertEquals(
          "CriteriaObjectInitializer should have been used as object initializer",
          1,
View Full Code Here

      name = "testSetLookupMethodPersistenceContext")
  public void testSetLookupMethodPersistenceContextUpperCase() throws Exception {
    try ( FullTextSessionBuilder builder = buildFullTextSessionBuilder( "PERSISTENCE_CONTEXT", null ) ) {
      indexTestData( builder );
      FullTextSession fullTextSession = builder.openFullTextSession();
      FullTextQuery query = fullTextSession.createFullTextQuery( new MatchAllDocsQuery() );
      query.list();
      fullTextSession.close();

      Assert.assertEquals(
          "PersistenceContextObjectInitializer should have been used as object initializer",
          1,
View Full Code Here

      name = "testSetLookupMethodPersistenceContext")
  public void testSetLookupMethodPersistenceContextLowerCase() throws Exception {
    try ( FullTextSessionBuilder builder = buildFullTextSessionBuilder( "persistence_context", null ) ) {
      indexTestData( builder );
      FullTextSession fullTextSession = builder.openFullTextSession();
      FullTextQuery query = fullTextSession.createFullTextQuery( new MatchAllDocsQuery() );
      query.list();
      fullTextSession.close();

      Assert.assertEquals(
          "PersistenceContextObjectInitializer should have been used as object initializer",
          1,
View Full Code Here

      name = "testSetLookupMethodPersistenceContext")
  public void testSetDatabaseRetrievalMethodUpperCase() throws Exception {
    try ( FullTextSessionBuilder builder = buildFullTextSessionBuilder( null, "FIND_BY_ID" ) ) {
      indexTestData( builder );
      FullTextSession fullTextSession = builder.openFullTextSession();
      FullTextQuery query = fullTextSession.createFullTextQuery( new MatchAllDocsQuery() );
      query.list();
      fullTextSession.close();

      Assert.assertEquals(
          "LookupObjectInitializer should have been used as object initializer",
          1,
View Full Code Here

      name = "testSetLookupMethodPersistenceContext")
  public void testSetDatabaseRetrievalMethodLoweCase() throws Exception {
    try ( FullTextSessionBuilder builder = buildFullTextSessionBuilder( null, "find_by_id" ) ) {
      indexTestData( builder );
      FullTextSession fullTextSession = builder.openFullTextSession();
      FullTextQuery query = fullTextSession.createFullTextQuery( new MatchAllDocsQuery() );
      query.list();
      fullTextSession.close();

      Assert.assertEquals(
          "LookupObjectInitializer should have been used as object initializer",
          1,
View Full Code Here

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

    QueryBuilder queryBuilder = fullTextSession.getSearchFactory()
        .buildQueryBuilder()
        .forEntity( FormulaAdd.class )
        .get();
    Query luceneQuery = queryBuilder.keyword().onField( "aplusB" ).ignoreAnalyzer().matching( value ).createQuery();
    FullTextQuery query = fullTextSession.createFullTextQuery( luceneQuery, FormulaAdd.class );
    List resultsList = query.list();
    transaction.commit();
    Assert.assertEquals( 1, resultsList.size() );
    FormulaAdd result = (FormulaAdd) resultsList.get( 0 );
    Assert.assertEquals( value, result.getAplusB() );
  }
View Full Code Here

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

    List<Facet> facetList = query.getFacetManager().getFacets( facetName );
    assertEquals( "Wrong number of facets", 4, facetList.size() );
  }
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.