// let parent initialize
super.init(initData);
// if there is no query, then we are done
if(searchRequest.getQuery() == null) {
pager = new SearchResultsPager(urlStrategy, searchRequest, results, false);
return;
}
// setup the search
IndexManager indexMgr = WebloggerFactory.getWeblogger().getIndexManager();
SearchOperation search = new SearchOperation(indexMgr);
search.setTerm(searchRequest.getQuery());
if(WebloggerRuntimeConfig.isSiteWideWeblog(searchRequest.getWeblogHandle())) {
this.websiteSpecificSearch = false;
} else {
search.setWebsiteHandle(searchRequest.getWeblogHandle());
}
if(StringUtils.isNotEmpty(searchRequest.getWeblogCategoryName())) {
search.setCategory(searchRequest.getWeblogCategoryName());
}
// execute search
indexMgr.executeIndexOperationNow(search);
if (search.getResultsCount() == -1) {
// this means there has been a parsing (or IO) error
this.errorMessage = I18nMessages.getMessages(searchRequest.getLocaleInstance()).getString("error.searchProblem");
} else {
Hits hits = search.getResults();
this.hits = search.getResultsCount();
// Convert the Hits into WeblogEntryData instances.
convertHitsToEntries(hits);
}
// search completed, setup pager based on results
pager = new SearchResultsPager(urlStrategy, searchRequest, results, (hits > (offset+limit)));
}