Package org.hibernate.search.query.dsl

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


           .andField("categories.name:ngrams").boostedTo(0.2f)
           .matching(textQuery)
           .createQuery();
       
        //Combine them for best results, note exact uses an higher boost:
        Query fullTextQuery = queryBuilder.bool()
           .should(queryToFindMathingNGrams)
           .should(queryToFindExactTerms)
           .createQuery();
       
        log.info("Executing fulltext query {0}", fullTextQuery);
View Full Code Here


         .andField("body:ngrams").boostedTo(0.4f)
         .matching(searchPattern)
         .createQuery();
     
      //Combine them for best results:
      Query fullTextQuery = queryBuilder.bool()
         .should(queryUsingEnglishStemmer)
         .should(queryUsingNGrams)
         .createQuery();
     
      return fullTextQuery;
View Full Code Here

         }
         sort = new Sort(sortField);
      }

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

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

         messageDescriptor = parsingResult.getTargetType();
         targetEntity = parsingResult.getTargetEntity();
         projections = parsingResult.getProjections();

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

      luceneQuery = parsingResult.getQuery();

      if (!cache.getCacheConfiguration().compatibility().enabled()) {
         // restrict on entity type
         QueryBuilder qb = searchFactory.buildQueryBuilder().forEntity(parsingResult.getTargetEntity()).get();
         luceneQuery = qb.bool()
               .must(qb.keyword().onField(TYPE_FIELD_NAME)
                           .ignoreFieldBridge()
                           .ignoreAnalyzer()
                           .matching(parsingResult.getTargetEntityName()).createQuery())
               .must(luceneQuery)
View Full Code Here

      luceneQuery = parsingResult.getQuery();

      if (!cache.getCacheConfiguration().compatibility().enabled()) {
         // restrict on entity type
         QueryBuilder qb = searchFactory.buildQueryBuilder().forEntity(parsingResult.getTargetEntity()).get();
         luceneQuery = qb.bool()
               .must(qb.keyword().onField(TYPE_FIELD_NAME)
                           .ignoreFieldBridge()
                           .ignoreAnalyzer()
                           .matching(parsingResult.getTargetEntityName()).createQuery())
               .must(luceneQuery)
View Full Code Here

        final TermMatchingContext context = qb.keyword().wildcard().onField("name");
        for (String field : additionalFields) {
            context.andField(field);
        }

        BooleanJunction<BooleanJunction> bool = qb.bool();
        for (String searchTerm : searchTerms) {
            bool.must(context.matching(String.format("*%s*", searchTerm.toLowerCase())).createQuery());
        }

        final FullTextQuery fullTextQuery = session.createFullTextQuery(bool.createQuery(), clazz);
View Full Code Here

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

    //must
    Query query = monthQb
        .bool()
        .must( monthQb.keyword().onField( "mythology" ).matching( "colder" ).createQuery() )
        .createQuery();

    List<Month> results = fullTextSession.createFullTextQuery( query, Month.class ).list();
View Full Code Here

    List<Month> results = fullTextSession.createFullTextQuery( query, Month.class ).list();
    assertEquals( 1, results.size() );
    assertEquals( "January", results.get( 0 ).getName() );

    //must not + all
    query = monthQb
        .bool()
          .should( monthQb.all().createQuery() )
          .must( monthQb.keyword().onField( "mythology" ).matching( "colder" ).createQuery() )
            .not()
          .createQuery();
View Full Code Here

    assertEquals( 2, results.size() );
    assertEquals( "February", results.get( 0 ).getName() );
    assertEquals( "March", results.get( 1 ).getName() );

    //implicit must not + all (not recommended)
    query = monthQb
        .bool()
          .must( monthQb.keyword().onField( "mythology" ).matching( "colder" ).createQuery() )
            .not()
          .createQuery();
    results = fullTextSession.createFullTextQuery( query, Month.class ).list();
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.