Hi,
I have problems to analyze Strings with whitespaces in H Search.
I use this method to search over multiple fields and return the corresponding List (List with hits)
Code:
public static List<Character> getResultList(String fullText, String gameFilter){
List<Character> result = null;
org.apache.lucene.search.Query luceneQuery = null;
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
FullTextSession fullTextSession = Search.createFullTextSession(session);
String[] fields = {"name","guild","server"};
MultiFieldQueryParser parser = new MultiFieldQueryParser(fields, new WhitespaceAnalyzer());
try {
luceneQuery = parser.parse(fullText);
} catch (ParseException e) {
e.printStackTrace();
}
org.hibernate.Query fullTextQuery = fullTextSession.createFullTextQuery( luceneQuery );
//look in the database for Character Objects
session.beginTransaction();
result = fullTextQuery.list(); //return a list of managed objects
session.getTransaction().commit();
return result;
}
My class character has got a String name where I can write "Surname name" for instance. If I am looking for this name by using Surname*, I am able to find the character. But if I use only Surname without the Wildcard I didn't find it. Could anybody help me here?
Thnx
Alex