I have integrated the hibernate search 3.1.1 with my existing application with Spring 2.5 and Hibernate core 3.3.2 GA. With hibernate-search-3.1.1, I am using apache lucene 2.4.1.
The problem I am facing is when I search a single word or multiple words in order, it searches perfectly and return the result but when I search multiple words out of order with blank spaces, it does not return any result. For Example, If I have a text indexed as
"Hello great world!"
Now If I search "Hello" or "great world", it returns result successfully but if I search "world Hello", it returns no result.
What I want is to be able return result if any of the complete or partial words matches on the indexed text. My source code is as below:
FullTextEntityManager fullTextEntityManager = Search.getFullTextEntityManager(this.entityManager);
// create native Lucene query
String[] fields = new String[] { "text", "description", "standard.title", "standard.briefPurpose", "standard.name" };
MultiFieldQueryParser parser = new MultiFieldQueryParser(fields, new StandardAnalyzer());
org.apache.lucene.search.Query query = null;
try {
query = parser.parse(searchTerm);
} catch (ParseException e) {
e.printStackTrace();
}
// wrap Lucene query in a javax.persistence.Query
FullTextQuery persistenceQuery = fullTextEntityManager.createFullTextQuery(query, Requirement.class);
// execute search
@SuppressWarnings("unchecked")
List<Requirement> result = persistenceQuery.getResultList();
return result;
Please help if I need to add any thing to support what I desire.