I have implemented the hibernate search, and I'm trying to return results when someone clicks the Search button to a table. Before Hibernate search we were using the hibernate criteria against SQL Server full-text capabilities, but wanted to drop the SQL Server dependency. So currently I'm using Hibernate Annotations, Spring MVC, and JSP.
My problem, is that I've having a hard time in the final step of returning the results...
I have a jsp search page, and when the user enters search criteria and clicks Search, it bulds a SearchCriteria object containing the information. Then in the ModelandView method of my Controller, I have this code:
Code:
ModelAndView mav = new ModelAndView("redirect:recordings.jsp");
RecordingSearchCriteria recordingSearchCriteria = ((RecordingsCommand) command).getRecordingSearchCriteria();
if (recordingSearchCriteria.getRecordingUID() != null) {
List list = recordingsService.getRecordingsWithLucene(recordingSearchCriteria);
mav.addObject("recordingSearchCriteria.recordingUID", recordingSearchCriteria.getRecordingUID());
}
return mav;
That calls my service, which calls my hibernateDAO class. Here is the method to return the list of Recording class results...
Code:
public List getRecordingsWithLucene(RecordingSearchCriteria recordingSearchCriteria) {
String searchQuery = "";
if (recordingSearchCriteria != null) {
if (recordingSearchCriteria.getRecordingUID() != null) {
searchQuery = "recordingID:" + recordingSearchCriteria.getRecordingUID().toString();
QueryParser parser = new QueryParser("luceneRequiredIdentifier", 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);
}
Session session = super.getSessionFactory().getCurrentSession();
FullTextSession ftSession = Search.createFullTextSession((session));
org.hibernate.Query query = ftSession.createFullTextQuery(luceneQuery, Recording.class);
return query.list();
} else
return null;
} else
return null;
}
Nothing is getting returned at all... I don't know if its getting to my index. Any help would be very grateful...