* @throws ProcessingException iff an error occurs
*/
private LuceneCocoonPager buildHits() throws ProcessingException {
if (queryString != null && queryString.length() != 0) {
Hits hits = null;
// TODO (VG): Move parts into compose/initialize/recycle
try {
lcs = (LuceneCocoonSearcher) this.manager.lookup(LuceneCocoonSearcher.ROLE);
Analyzer analyzer = LuceneCocoonHelper.getAnalyzer("org.apache.lucene.analysis.standard.StandardAnalyzer");
lcs.setAnalyzer(analyzer);
// get the directory where the index resides
Directory directory = LuceneCocoonHelper.getDirectory(index, false);
lcs.setDirectory(directory);
hits = lcs.search(queryString, LuceneXMLIndexer.BODY_FIELD);
} catch (IOException ioe) {
throw new ProcessingException("IOException in search", ioe);
} catch (ComponentException ce) {
throw new ProcessingException("ComponentException in search", ce);
} finally {
if (lcs != null) {
this.manager.release(lcs);
lcs = null;
}
}
// wrap the hits by an pager help object for accessing only a range of hits
LuceneCocoonPager pager = new LuceneCocoonPager(hits);
int start_index = START_INDEX_DEFAULT;
if (this.startIndex != null) {
start_index = this.startIndex.intValue();
if (start_index <= 0) {
start_index = 0;
}
pager.setStartIndex(start_index);
}
int page_length = PAGE_LENGTH_DEFAULT;
if (this.pageLength != null) {
page_length = this.pageLength.intValue();
if (page_length <= 0) {
page_length = hits.length();
}
pager.setCountOfHitsPerPage(page_length);
}
return pager;