Package org.hibernate.search.jpa

Examples of org.hibernate.search.jpa.FullTextEntityManager.createFullTextQuery()


    em.getTransaction().begin();
    QueryParser parser = new QueryParser( getTargetLuceneVersion(), "title", TestConstants.stopAnalyzer );
    Query query = parser.parse( "saltQty:noword" );
    assertEquals( 0, em.createFullTextQuery( query ).getResultList().size() );
    query = new TermQuery( new Term( "saltQty", "23" ) );
    assertEquals( "getResultList", 1, em.createFullTextQuery( query ).getResultList().size() );
    assertEquals(
        "getSingleResult and object retrieval", 23,
        ( (Bretzel) em.createFullTextQuery( query ).getSingleResult() ).getSaltQty()
    );
    assertEquals( 1, em.createFullTextQuery( query ).getResultSize() );
View Full Code Here


    assertEquals( 0, em.createFullTextQuery( query ).getResultList().size() );
    query = new TermQuery( new Term( "saltQty", "23" ) );
    assertEquals( "getResultList", 1, em.createFullTextQuery( query ).getResultList().size() );
    assertEquals(
        "getSingleResult and object retrieval", 23,
        ( (Bretzel) em.createFullTextQuery( query ).getSingleResult() ).getSaltQty()
    );
    assertEquals( 1, em.createFullTextQuery( query ).getResultSize() );
    em.getTransaction().commit();

    em.clear();
View Full Code Here

    assertEquals( "getResultList", 1, em.createFullTextQuery( query ).getResultList().size() );
    assertEquals(
        "getSingleResult and object retrieval", 23,
        ( (Bretzel) em.createFullTextQuery( query ).getSingleResult() ).getSaltQty()
    );
    assertEquals( 1, em.createFullTextQuery( query ).getResultSize() );
    em.getTransaction().commit();

    em.clear();

    em.getTransaction().begin();
View Full Code Here

    final QueryBuilder builder = em.getSearchFactory().buildQueryBuilder().forEntity( POI.class ).get();

    org.apache.lucene.search.Query luceneQuery = builder.spatial().onCoordinates( "location" )
        .within( 100, Unit.KM ).ofLatitude( centerLatitude ).andLongitude( centerLongitude ).createQuery();

    FullTextQuery hibQuery = em.createFullTextQuery( luceneQuery, POI.class );
    hibQuery.setProjection( FullTextQuery.THIS, FullTextQuery.SPATIAL_DISTANCE );
    hibQuery.setSpatialParameters( centerLatitude, centerLongitude, "location" );
    List results = hibQuery.getResultList();
    Object[] firstResult = (Object[]) results.get( 0 );
    Object[] secondResult = (Object[]) results.get( 1 );
View Full Code Here

    final QueryBuilder builder = em.getSearchFactory().buildQueryBuilder().forEntity( POI.class ).get();

    org.apache.lucene.search.Query luceneQuery = builder.spatial().onCoordinates( "location" )
        .within( 100, Unit.KM ).ofLatitude( centerLatitude ).andLongitude( centerLongitude ).createQuery();

    FullTextQuery hibQuery = em.createFullTextQuery( luceneQuery, POI.class );
    Sort distanceSort = new Sort( new DistanceSortField( centerLatitude, centerLongitude, "location" ) );
    hibQuery.setSort( distanceSort );
    hibQuery.setProjection( FullTextQuery.THIS, FullTextQuery.SPATIAL_DISTANCE );
    hibQuery.setSpatialParameters( centerLatitude, centerLongitude, "location" );
    List results = hibQuery.getResultList();
View Full Code Here

        .within( 1.8097233616663808, Unit.KM )
          .ofLatitude( centerLatitude )
          .andLongitude( centerLongitude )
        .createQuery();

    FullTextQuery hibQuery = em.createFullTextQuery( luceneQuery, POI.class );
    Sort distanceSort = new Sort( new DistanceSortField( centerLatitude, centerLongitude, "location" ) );
    hibQuery.setSort( distanceSort );
    hibQuery.setMaxResults( 1000 );
    hibQuery.setProjection( FullTextQuery.THIS, FullTextQuery.SPATIAL_DISTANCE );
    hibQuery.setSpatialParameters( centerLatitude, centerLongitude, "location" );
View Full Code Here

    final QueryBuilder builder = em.getSearchFactory().buildQueryBuilder().forEntity( POI.class ).get();

    org.apache.lucene.search.Query luceneQuery = builder.spatial().onCoordinates( "location" ).within( 100, Unit.KM ).ofLatitude( centerLatitude )
        .andLongitude( centerLongitude ).createQuery();

    FullTextQuery hibQuery = em.createFullTextQuery( luceneQuery, POI.class );
    Sort distanceSort = new Sort( new DistanceSortField( centerLatitude, centerLongitude, "location" ) );
    hibQuery.setSort( distanceSort );
    hibQuery.setProjection( FullTextQuery.THIS, FullTextQuery.SPATIAL_DISTANCE );
    // Set max results to 3 when 6 documents are stored:
    hibQuery.setMaxResults( 3 );
View Full Code Here

          .createQuery());
    } else {
      booleanJunction.must(projectQueryBuilder.all().createQuery());
    }
   
    return fullTextEntityManager.createFullTextQuery(booleanJunction.createQuery(), Project.class);
  }
}
View Full Code Here

          .createQuery());
    } else {
      booleanJunction.must(artifactQueryBuilder.all().createQuery());
    }
   
    return fullTextEntityManager.createFullTextQuery(booleanJunction.createQuery(), Artifact.class);
  }
 
  @SuppressWarnings("unchecked")
  @Override
  public List<Artifact> searchRecommended(String searchTerm, Integer limit, Integer offset) throws ServiceException {
View Full Code Here

      booleanJunction.must(booleanQuery);
    } catch (ParseException e) {
      throw new ServiceException(String.format("Error parsing request: %1$s", searchTerm), e);
    }
   
    return fullTextEntityManager.createFullTextQuery(booleanJunction.createQuery(), Artifact.class);
  }
}
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.