Examples of createFullTextQuery()


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

      Assert.hasText(query);
        try {
            FullTextEntityManager fullTextEntityManager = Search.getFullTextEntityManager(getEntityManager());
            List<String> indexedFields = getAllIndexedFields(clazz, "");
            MultiFieldQueryParser parser = new MultiFieldQueryParser(indexedFields.toArray(new String[indexedFields.size()]), new StandardAnalyzer());
            FullTextQuery hq = fullTextEntityManager.createFullTextQuery(parser.parse(query.trim().replaceAll(" ", "* ") + "*"), clazz);
            hq.setMaxResults(number > 0 ? number : MAX_RESULTS);
            hq.setFirstResult(offset > 0 ? offset : 0);
            return hq.getResultList();
        } catch (Exception ex) {
            throw new IWebMvcException("Could not perform search", ex);
View Full Code Here

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

    final QueryBuilder b = ftem.getSearchFactory()
        .buildQueryBuilder()
        .forEntity( Insurance.class )
        .get();
    final Query lq = b.keyword().onField( "name" ).matching( "Macif" ).createQuery();
    final FullTextQuery ftQuery = ftem.createFullTextQuery( lq, Insurance.class );
    ftQuery.initializeObjectsWith( ObjectLookupMethod.SKIP, DatabaseRetrievalMethod.FIND_BY_ID );
    final List<Insurance> resultList = ftQuery.getResultList();
    assertThat( getFactory().getPersistenceUnitUtil().isLoaded( resultList.get( 0 ) ) ).isTrue();
    assertThat( resultList ).hasSize( 1 );
    for ( Object e : resultList ) {
View Full Code Here

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

      getTransactionManager().begin();
      fullTextEm = Search.getFullTextEntityManager( createEntityManager() );
      QueryBuilder queryBuilder = fullTextEm.getSearchFactory().buildQueryBuilder().forEntity( IndexedNews.class ).get();
      Query luceneQuery = queryBuilder.keyword().wildcard().onField( "newsId" ).ignoreFieldBridge().matching( "tit*" ).createQuery();
      @SuppressWarnings("unchecked")
      List<IndexedNews> list = fullTextEm.createFullTextQuery( luceneQuery ).getResultList();
      assertThat( list ).hasSize( 1 );

      List<IndexedLabel> labels = list.get( 0 ).getLabels();
      assertThat( labels ).hasSize( 2 );
      assertThat( contains( labels, "massindex" ) ).isTrue();
View Full Code Here

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

      getTransactionManager().begin();
      fullTextEm = Search.getFullTextEntityManager( createEntityManager() );
      QueryBuilder b = fullTextEm.getSearchFactory().buildQueryBuilder().forEntity( IndexedLabel.class ).get();
      {
        Query luceneQuery = b.keyword().wildcard().onField( "name" ).matching( "tes*" ).createQuery();
        List<IndexedLabel> labels = fullTextEm.createFullTextQuery( luceneQuery ).getResultList();
        assertThat( labels ).hasSize( 1 );
        assertThat( contains( labels, "test" ) ).isTrue();
      }
      {
        Query luceneQuery = b.keyword().wildcard().onField( "name" ).matching( "mas*" ).createQuery();
View Full Code Here

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

        assertThat( labels ).hasSize( 1 );
        assertThat( contains( labels, "test" ) ).isTrue();
      }
      {
        Query luceneQuery = b.keyword().wildcard().onField( "name" ).matching( "mas*" ).createQuery();
        List<IndexedLabel> labels = fullTextEm.createFullTextQuery( luceneQuery ).getResultList();
        assertThat( labels ).hasSize( 1 );
        assertThat( contains( labels, "massindex" ) ).isTrue();
      }
      operationSuccessful = true;
    }
View Full Code Here

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

        try {
            qry = HibernateSearchJpaTools.generateQuery(searchTerm, this.persistentClass, entityManager, defaultAnalyzer);
        } catch (ParseException ex) {
            throw new SearchException(ex);
        }
        org.hibernate.search.jpa.FullTextQuery hibQuery = fullTextEntityManager.createFullTextQuery(qry, this.persistentClass);
        // filter search results by owner.id value:
        // hibQuery.enableFullTextFilter("owned").setParameter("ownerId", owner.getId().toString());
        return hibQuery.getResultList();
    }
View Full Code Here

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

  public static Member findWithEmail(EntityManager em, String email) {
    FullTextEntityManager ftem = Search.getFullTextEntityManager( em );
    QueryBuilder b = ftem.getSearchFactory().buildQueryBuilder().forEntity( Member.class ).get();
    Query lq = b.keyword().wildcard().onField( "email" ).matching( email ).createQuery();
    Object uniqueResult = ftem.createFullTextQuery( lq ).getSingleResult();
    return (Member) uniqueResult;
  }
}
View Full Code Here

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

    );

    org.apache.lucene.search.Query luceneQuery;
    luceneQuery = parser.parse( searchQuery );

    final FullTextQuery query = ftEm.createFullTextQuery( luceneQuery, Book.class );

    return query;
  }

}
View Full Code Here

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

                boostPerField);

        org.apache.lucene.search.Query luceneQuery;
        luceneQuery = parser.parse(searchQuery);

        final FullTextQuery query = ftEm.createFullTextQuery(luceneQuery, Book.class);

        return query;
    }

}
View Full Code Here

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

    );

    org.apache.lucene.search.Query luceneQuery;
    luceneQuery = parser.parse( searchQuery );

    final FullTextQuery query = ftEm.createFullTextQuery( luceneQuery, Book.class );

    return query;
  }
}
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.