Hi,
I am using Hibernate search.
I have a search text box in my jsp page. If i enter some text, it returns correct result. But if i leave empty message and click the search button, it did not return any records.
This is my code,
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
String searchQuery = "Admin"; String[] userFields = {"firstName", "lastName", "role_groupName", "userId"}; QueryParser parser = new MultiFieldQueryParser(userFields, new StandardAnalyzer()); org.apache.lucene.search.Query luceneQuery; try { luceneQuery = parser.parse(searchQuery); } catch (ParseException e) { throw new RuntimeException("Unable to parse query: " + searchQuery, e); }
FullTextSession ftSession = Search.getFullTextSession(session); org.hibernate.Query query = ftSession.createFullTextQuery(luceneQuery, UserVO.class);
List results = query.list(); System.out.println("Result size:" + results.size()); }