From 93a463db69a6f497f3ff053e90e7165db24af9f1 Mon Sep 17 00:00:00 2001 From: Josef Rokos Date: Mon, 13 Apr 2015 09:56:04 +0200 Subject: [PATCH] =?UTF-8?q?Upraveno=20t=C5=99=C3=ADd=C4=9Bn=C3=AD=20v?= =?UTF-8?q?=C3=BDsledku=20fulltextov=C3=A9ho=20vyhled=C3=A1v=C3=A1n=C3=AD-?= =?UTF-8?q?=20nin=C3=AD=20se=20t=C5=99=C3=ADd=C3=AD=20podle=20relevancve?= =?UTF-8?q?=20v=C3=BDsledku.=20refs=20#211?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../isspst/services/fulltext/FullTextServiceImpl.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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(); }