use of org.apache.wiki.search.QueryItem in project jspwiki by apache.
the class TwoXWikiPageProvider method findPages.
/**
* {@inheritDoc}
*/
@Override
public Collection<SearchResult> findPages(final QueryItem[] query) {
final TreeSet<SearchResult> res = new TreeSet<>(new SearchResultComparator());
final SearchMatcher matcher = new SearchMatcher(engine, query);
final Map<String, WikiPage> wikipages = pages.entrySet().stream().map(e -> new AbstractMap.SimpleEntry<>(e.getKey(), e.getValue().get(e.getValue().size() - 1))).collect(Collectors.toMap(AbstractMap.SimpleEntry::getKey, AbstractMap.SimpleEntry::getValue));
for (final String wikipage : wikipages.keySet()) {
final String pagetext = contents.get(wikipage).get(contents.get(wikipage).size() - 1);
try {
final SearchResult comparison = matcher.matchPageContent(wikipage, pagetext);
if (comparison != null) {
res.add(comparison);
}
} catch (final IOException e) {
// ok to ignore, shouldn't happen
}
}
return res;
}
Aggregations