diff --git a/src/main/java/info/bukova/isspst/services/fulltext/FullTextServiceImpl.java b/src/main/java/info/bukova/isspst/services/fulltext/FullTextServiceImpl.java index 518a32a0..e618ba70 100644 --- a/src/main/java/info/bukova/isspst/services/fulltext/FullTextServiceImpl.java +++ b/src/main/java/info/bukova/isspst/services/fulltext/FullTextServiceImpl.java @@ -7,7 +7,9 @@ import info.bukova.isspst.data.User; import info.bukova.isspst.services.ModuleNotActiveException; import info.bukova.isspst.sort.ReflectionTools; import org.apache.lucene.search.Query; +import org.apache.lucene.search.Sort; import org.hibernate.Hibernate; +import org.hibernate.search.FullTextQuery; import org.hibernate.search.FullTextSession; import org.hibernate.search.Search; import org.hibernate.search.annotations.IndexedEmbedded; @@ -22,7 +24,11 @@ import java.lang.annotation.Annotation; import java.lang.reflect.Field; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; public class FullTextServiceImpl implements FullTextService { @@ -56,7 +62,8 @@ public class FullTextServiceImpl implements FullTextService { QueryBuilder qb = session.getSearchFactory().buildQueryBuilder().forEntity(entityClass).get(); Query luceneQuery = qb.keyword().onFields(fields).matching(word).createQuery(); - org.hibernate.Query hiberQuery = session.createFullTextQuery(luceneQuery, entityClass); + FullTextQuery hiberQuery = session.createFullTextQuery(luceneQuery, entityClass); + hiberQuery.setSort(Sort.RELEVANCE); return hiberQuery.list(); }