Package org.hibernate.search.query.dsl

Examples of org.hibernate.search.query.dsl.QueryBuilder.bool()


  @Test(expected = SearchException.class)
  public void testIllegalBooleanJunction() {
    final QueryBuilder monthQb = fullTextSession.getSearchFactory()
        .buildQueryBuilder().forEntity( Month.class ).get();
    //forgetting to set any condition on the boolean, an exception shall be thrown:
    BooleanJunction<BooleanJunction> booleanJunction = monthQb.bool();
    assertTrue( booleanJunction.isEmpty() );
    Query query = booleanJunction.createQuery();
    Assert.fail( "should not reach this point" );
  }
View Full Code Here


    final QueryBuilder monthQb = fullTextSession.getSearchFactory()
        .buildQueryBuilder().forEntity( Month.class ).get();


    //combined query, January and february both contain whitening but February in a longer text
    Query query = monthQb
        .bool()
        .should( monthQb.keyword().onField( "mythology" ).matching( "whitening" ).createQuery() )
        .should( monthQb.keyword().onField( "history" ).matching( "whitening" ).createQuery() )
        .createQuery();
View Full Code Here

    assertEquals( 2, results.size() );
    assertEquals( "January", results.get( 0 ).getName() );

    //boosted query, January and february both contain whitening but February in a longer text
    //since history is boosted, February should come first though
    query = monthQb
        .bool()
        .should( monthQb.keyword().onField( "mythology" ).matching( "whitening" ).createQuery() )
        .should( monthQb.keyword().onField( "history" ).boostedTo( 30 ).matching( "whitening" ).createQuery() )
        .createQuery();
View Full Code Here

      for ( int i = 0; i < iterations; i++ ) {
        Point center = Point.fromDegrees( random.nextDouble() * 2 + 44 , random.nextDouble() * 2 + 3 );
        double radius = 25.0d;
        Rectangle boundingBox = Rectangle.fromBoundingCircle( center, radius );

        query = queryBuilder.bool()
            .must(
                queryBuilder.range()
                    .onField( "latitude" )
                    .from( boundingBox.getLowerLeft().getLatitude() )
                    .to( boundingBox.getUpperRight().getLatitude() )
View Full Code Here

        if ( i > warmUp ) {
          doubleRangeTotalDuration += duration;
        }
        session.clear();

        query = queryBuilder.bool()
            .must(
                queryBuilder.range()
                    .onField( "latitude" )
                    .from( boundingBox.getLowerLeft().getLatitude() )
                    .to( boundingBox.getUpperRight().getLatitude() )
View Full Code Here

    QueryBuilder queryBuilder = fullTextSession.getSearchFactory()
        .buildQueryBuilder()
        .forEntity( Item.class )
        .get();

    Query rootQuery = queryBuilder.bool()
        .must( queryBuilder.range().onField( "price" ).above( 10000l ).createQuery() )
        .must( queryBuilder.range().onField( "price" ).below( 20000l ).createQuery() )
        .createQuery();

    @SuppressWarnings( "unchecked" )
View Full Code Here

         targetEntity = parsingResult.getTargetEntity();
         messageDescriptor = serCtx.getMessageDescriptor(parsingResult.getTargetEntityName());
         projections = parsingResult.getProjections();

         QueryBuilder qb = searchManager.getSearchFactory().buildQueryBuilder().forEntity(targetEntity).get();
         luceneQuery = qb.bool()
               .must(qb.keyword().onField(TYPE_FIELD_NAME).ignoreFieldBridge().ignoreAnalyzer().matching(messageDescriptor.getFullName()).createQuery())
               .must(parsingResult.getQuery())
               .createQuery();
      }
View Full Code Here

         LuceneProcessingChain processingChain = new LuceneProcessingChain.Builder(searchFactory, entityNamesResolver)
               .buildProcessingChainForDynamicEntities(fieldBridgeProvider);
         parsingResult = queryParser.parseQuery(request.getJpqlString(), processingChain);

         QueryBuilder qb = searchManager.getSearchFactory().buildQueryBuilder().forEntity(parsingResult.getTargetEntity()).get();
         Query luceneQuery = qb.bool()
               .must(qb.keyword().onField(TYPE_FIELD_NAME).ignoreFieldBridge().ignoreAnalyzer().matching(parsingResult.getTargetEntityName()).createQuery())
               .must(parsingResult.getQuery())
               .createQuery();

         cacheQuery = searchManager.getQuery(luceneQuery, parsingResult.getTargetEntity());
View Full Code Here

    FullTextEntityManager fullTextEntityManager = Search.getFullTextEntityManager(getEntityManager());
   
    QueryBuilder projectQueryBuilder = fullTextEntityManager.getSearchFactory().buildQueryBuilder()
        .forEntity(Project.class).get();
   
    BooleanJunction<?> booleanJunction = projectQueryBuilder.bool();
    if (StringUtils.hasText(searchTerm)) {
      booleanJunction.must(projectQueryBuilder
          .keyword()
          .fuzzy().withPrefixLength(1).withThreshold(0.8F)
          .onField(Binding.project().name().getPath())
View Full Code Here

    FullTextEntityManager fullTextEntityManager = Search.getFullTextEntityManager(getEntityManager());
   
    QueryBuilder userQueryBuilder = fullTextEntityManager.getSearchFactory().buildQueryBuilder()
        .forEntity(User.class).get();
   
    BooleanJunction<?> booleanJunction = userQueryBuilder.bool();
   
    if (StringUtils.hasText(searchTerm)) {
      booleanJunction.must(userQueryBuilder
          .keyword()
          .fuzzy().withPrefixLength(1).withThreshold(0.8F)
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.