Package org.hibernate.search.query.dsl

Examples of org.hibernate.search.query.dsl.TermMatchingContext


        final FullTextEntityManager session = Search.getFullTextEntityManager(entityManager);
        QueryBuilder qb = session.getSearchFactory()
                .buildQueryBuilder().forEntity(clazz).get();

        String[] searchTerms = keyword.split(" ");
        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);
        fullTextQuery.setCriteriaQuery(query);
        return fullTextQuery;
View Full Code Here


  @SuppressWarnings("unchecked")
  private List<ArrayBridgeTestEntity> findEmbeddedNullResults(String fieldName, Object value, boolean checkNullToken) {
    QueryBuilder queryBuilder = fullTextSession.getSearchFactory().buildQueryBuilder()
        .forEntity( ArrayBridgeTestEntity.class ).get();
    TermMatchingContext termMatchingContext = queryBuilder.keyword().onField( fieldName );
    if ( checkNullToken ) {
      termMatchingContext.ignoreFieldBridge();
    }
    Query query = termMatchingContext.ignoreAnalyzer().matching( value ).createQuery();
    return fullTextSession.createFullTextQuery( query, ArrayBridgeTestEntity.class ).list();
  }
View Full Code Here

  @SuppressWarnings("unchecked")
  private List<ArrayBridgeTestEntity> findResults(String fieldName, Object value, boolean checkNullToken) {
    QueryBuilder queryBuilder = fullTextSession.getSearchFactory().buildQueryBuilder()
        .forEntity( ArrayBridgeTestEntity.class ).get();
    TermMatchingContext termMatchingContext = queryBuilder.keyword().onField( fieldName );
    if ( checkNullToken ) {
      termMatchingContext.ignoreFieldBridge();
    }
    Query query = termMatchingContext.matching( value ).createQuery();
    return fullTextSession.createFullTextQuery( query, ArrayBridgeTestEntity.class ).list();
  }
View Full Code Here

  @SuppressWarnings("unchecked")
  private List<MapBridgeTestEntity> findEmbeddedNullResults(String fieldName, Object value, boolean checkNullToken) {
    QueryBuilder queryBuilder = fullTextSession.getSearchFactory().buildQueryBuilder()
        .forEntity( MapBridgeTestEntity.class ).get();
    TermMatchingContext termMatchingContext = queryBuilder.keyword().onField( fieldName );
    if ( checkNullToken ) {
      termMatchingContext.ignoreFieldBridge();
    }
    Query query = termMatchingContext.ignoreAnalyzer().matching( value ).createQuery();
    return fullTextSession.createFullTextQuery( query, MapBridgeTestEntity.class ).list();
  }
View Full Code Here

  @SuppressWarnings("unchecked")
  private List<MapBridgeTestEntity> findResults(String fieldName, Object value, boolean checkNullToken) {
    QueryBuilder queryBuilder = fullTextSession.getSearchFactory().buildQueryBuilder()
        .forEntity( MapBridgeTestEntity.class ).get();
    TermMatchingContext termMatchingContext = queryBuilder.keyword().onField( fieldName );
    if ( checkNullToken ) {
      termMatchingContext.ignoreFieldBridge();
    }
    Query query = termMatchingContext.matching( value ).createQuery();
    return fullTextSession.createFullTextQuery( query, MapBridgeTestEntity.class ).list();
  }
View Full Code Here

  @SuppressWarnings("unchecked")
  private List<IterableBridgeTestEntity> findEmbeddedNullResults(String fieldName, Object value, boolean checkForNullToken) {
    QueryBuilder queryBuilder = fullTextSession.getSearchFactory().buildQueryBuilder()
        .forEntity( IterableBridgeTestEntity.class ).get();
    TermMatchingContext termMatchingContext = queryBuilder.keyword().onField( fieldName );
    if ( checkForNullToken ) {
      termMatchingContext.ignoreFieldBridge();
    }
    Query query = termMatchingContext
        .ignoreAnalyzer()
        .matching( value ).createQuery();
    return fullTextSession.createFullTextQuery( query, IterableBridgeTestEntity.class ).list();
  }
View Full Code Here

  @SuppressWarnings("unchecked")
  private List<IterableBridgeTestEntity> findResults( String fieldName, Object value, boolean checkRawValue) {
    QueryBuilder queryBuilder = fullTextSession.getSearchFactory().buildQueryBuilder()
        .forEntity( IterableBridgeTestEntity.class ).get();
    TermMatchingContext termMatchingContext = queryBuilder.keyword().onField( fieldName );
    if ( checkRawValue ) {
      termMatchingContext.ignoreFieldBridge();
    }
    Query query = termMatchingContext.matching( value ).createQuery();
    return fullTextSession.createFullTextQuery( query, IterableBridgeTestEntity.class ).list();
  }
View Full Code Here

TOP

Related Classes of org.hibernate.search.query.dsl.TermMatchingContext

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.