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;