Combining JPA with HIbernate Search Lucene Query

I can easily find JPA objects using a full-text query using Hibernate Search:

FullTextEntityManager fullTextEntityManager = 
        Search.getFullTextEntityManager(this.entityManager);

QueryBuilder queryBuilder = fullTextEntityManager.getSearchFactory()
        .buildQueryBuilder().forEntity(MyBean.class).get();

org.apache.lucene.search.Query luceneQuery = queryBuilder.keyword()
        .onFields("foo", "bar").matching("needle").createQuery();

javax.persistence.Query jpaQuery = fullTextEntityManager
        .createFullTextQuery(luceneQuery, MyBean.class);

List<MyBean> fulltextResult = jpaQuery.getResultList();

And that’s great. But how can I combine luceneQueryin an existing JPA request? For example, as a predicate for use in an expression CriteriaBuilder.where(). I think this is possible, since Hibernate Search extracts entity identifiers from its indexes and finally uses them in the JPA query to get the result, but I don’t know if there is any method next getResultList()to get the query in another intermediate types such as javax.persistence.criteria.Predicate.

+4
source share
1 answer

projections lucene, , , in jpa.

0

All Articles