Hibernate Search Example - Search with JPA
Example 1.9. Using JPA to create and execute a search EntityManager em = entityManagerFactory.createEntityManager(); FullTextEntityManager fullTextEntityManager =     org.hibernate.search.jpa.Search.getFullTextEntityManager(em); em.getTransaction().begin(); // create native Lucene query unsing the query DSL // alternatively you can write the Lucene query using the Lucene query parser // or the Lucene programmatic API. The Hibernate Search DSL is recommended though QueryBuilder qb = fullTextSession.getSearchFactory()     .buildQueryBuilder().forEntity( Book.class ).get(); org.apache.lucene.search.Query query = qb   .keyword()   .onFields("title", "subtitle", "authors.name", "publicationDate")   .matching("Java rocks!");   .createQuery(); // wrap Lucene query in a javax.persistence.Query javax.persistence.Query persistenceQuery =     fullTextEntityManager.createFullTextQuery(query, Book.class); // execute search List result = persistenceQuery.getResultList(); em.getTransaction().commit(); em.close();