use of com.celements.search.lucene.LuceneSearchException in project celements-blog by celements.
the class ArticleEngineLucene method getArticles.
@Override
public List<Article> getArticles(ArticleLoadParameter param) throws ArticleLoadException {
try {
List<Article> articles = new ArrayList<>();
LuceneQuery query = queryBuilder.build(param);
if (query != null) {
LuceneSearchResult result = searchService.searchWithoutChecks(query, param.getSortFields(), Arrays.asList("default", param.getLanguage()));
result.setOffset(param.getOffset()).setLimit(param.getLimit());
for (EntityReference ref : result.getResults()) {
if (ref instanceof DocumentReference) {
XWikiDocument doc = getContext().getWiki().getDocument((DocumentReference) ref, getContext());
try {
articles.add(new Article(doc, getContext()));
} catch (EmptyArticleException exc) {
LOGGER.warn("getArticles: empty article '{}'", exc, doc);
}
} else {
LOGGER.warn("getArticles: not expecting Attachment as search result '{}' " + "for search '{}'", ref, param);
}
}
} else {
LOGGER.warn("got null from query builder for '" + param + "'");
}
return articles;
} catch (LuceneSearchException lse) {
throw new ArticleLoadException(lse);
} catch (XWikiException xwe) {
throw new ArticleLoadException(xwe);
}
}
Aggregations