use of org.xwiki.rest.internal.resources.search.SearchSource in project xwiki-platform by xwiki.
the class BaseSearchResult method searchQuery.
/**
* Search for query using xwql, hql, lucene. Limit the search only to Pages. Search for keyword
*
* @param query the query to be executed
* @param queryTypeString can be "xwql", "hql" or "lucene".
* @param orderField the field to be used to order the results.
* @param order "asc" or "desc"
* @param number number of results to be returned
* @param start 0-based start offset.
* @return a list of {@link SearchResult} objects containing the found items, or an empty list if the specified
* query type string doesn't represent a supported query type.
*/
protected List<SearchResult> searchQuery(String query, String queryTypeString, String wikiName, String wikis, boolean hasProgrammingRights, String orderField, String order, boolean distinct, int number, int start, Boolean withPrettyNames, String className) throws Exception {
String currentWiki = Utils.getXWikiContext(componentManager).getWikiId();
/* This try is just needed for executing the finally clause. */
try {
if (wikiName != null) {
Utils.getXWikiContext(componentManager).setWikiId(wikiName);
}
List<SearchResult> result;
if (queryTypeString != null) {
SearchSource searchSource = this.componentManager.getInstance(SearchSource.class, queryTypeString.toLowerCase());
result = searchSource.search(query, wikiName, wikis, hasProgrammingRights, orderField, order, distinct, number, start, withPrettyNames, className, uriInfo);
} else {
result = new ArrayList<SearchResult>();
}
return result;
} finally {
Utils.getXWikiContext(componentManager).setWikiId(currentWiki);
}
}
Aggregations