lundi 6 avril 2015

Hibernate full text search matching

how to find all mathing of 'query' I have users Alex, Andrei When i write query like 'A' and have result 0 records. If i want to find user with name Alex, i must to write query with Full name and right word case.


I want send query = 'e' end recive 2 reccords ;)



Session s = session.getCurrentSession();

FullTextSession fullTextSession = Search.getFullTextSession(s);

QueryBuilder qb = fullTextSession.getSearchFactory()
.buildQueryBuilder().forEntity(User.class).get();
org.apache.lucene.search.Query q = qb
.keyword().onFields("name")
.matching(query)
.createQuery();

org.hibernate.Query hibQuery =
fullTextSession.createFullTextQuery(q, User.class);

List<User> results = hibQuery.list();

Aucun commentaire:

Enregistrer un commentaire