public <T extends DomainEntity> List<T> search(Class<T> clazz, String field, String query, int offset, int number) {
FullTextEntityManager fullTextEntityManager = Search.createFullTextEntityManager(getEntityManager());
MultiFieldQueryParser parser = new MultiFieldQueryParser(getAllIndexedFields(clazz, field), new StandardAnalyzer());
try {
org.apache.lucene.search.Query parsedquery = parser.parse(query.trim().replaceAll(" ", "* ") + "*");
FullTextQuery hq = fullTextEntityManager.createFullTextQuery(parsedquery, 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);
}
}