I am just starting with Hibernate Search. The code I use to perform the search is taken from the reference guide:
FullTextEntityManager fullTextEntityManager =
Search.getFullTextEntityManager(em);
EntityTransaction transaction = em.getTransaction();
try
{
transaction.begin();
SearchFactory sf = fullTextEntityManager.getSearchFactory();
QueryBuilder qb = sf
.buildQueryBuilder().forEntity(Item.class).get();
org.apache.lucene.search.Query query = qb
.keyword()
.onFields("title", "description")
.matching(queryString)
.createQuery();
javax.persistence.Query persistenceQuery =
fullTextEntityManager.createFullTextQuery(query, Item.class);
@SuppressWarnings("unchecked")
List<Item> result = persistenceQuery.getResultList();
transaction.commit();
return result;
}
catch (RuntimeException e)
{
transaction.rollback();
throw e;
}
I notice that query terms are interpreted as terms in a clause (OR). I would like them to be interpreted as compound terms.
source
share