We are using Hibernate Search extensively in a new application, but I am running into performance issues with querying.
The issue stems from the fact that I can't control the SQL that is generated from and follows a Hibernate Search (Lucene) query.
Consider the following:
Code:
FullTextSession fullTextSession = Search
.getFullTextSession(this.sessionFactory.getCurrentSession());
MultiFieldQueryParser parser = new MultiFieldQueryParser(
Version.LUCENE_29, fields, fullTextSession.getSearchFactory()
.getAnalyzer(MasterIdentity.class));
List<MasterIdentity> list = null;
try {
org.apache.lucene.search.Query query = parser.parse(searchQuery);
org.hibernate.search.FullTextQuery fullTextQuery = fullTextSession
.createFullTextQuery(query, MasterIdentity.class)
.setMaxResults(results).setFirstResult(index);
org.apache.lucene.search.Sort sorter = new Sort();
if (sortFields != null && sortFields.length > 0) {
sorter.setSort(sortFields);
} else {
SortField sf = new SortField(searchQuery, SortField.STRING);
sorter.setSort(sf);
}
fullTextQuery.setSort(sorter);
list = fullTextQuery.list();
} catch (ParseException e) {
e.printStackTrace();
}
At "fullTextQuery.list();", Hibernate Search executes the Lucene query, is returned a stub result set, and then executes a standard "select this_.active_bid as active1_1_7_, this_.ATP as ATP1_7_, this_.create_date as create3_1_7_....."
The resulting query takes quite a while and includes several left outer joins. Is there a way I get in between Lucene and Hibernate and have my query constructed the way I want it constructed after the Lucene search is completed, but before the stub Hibernate object is populated?
Thanks so much.