use of org.springframework.data.mongodb.core.query.TextCriteria in project ocvn by devgateway.
the class GenericOCDSController method textSearchQuery.
/**
* Creates a mongodb query for searching based on text index, sorts the results by score
*
* @param request
* @return
*/
protected Query textSearchQuery(final TextSearchRequest request) {
PageRequest pageRequest = new PageRequest(request.getPageNumber(), request.getPageSize());
Query query = null;
if (request.getText() == null) {
query = new Query();
} else {
query = TextQuery.queryText(new TextCriteria().matching(request.getText())).sortByScore();
}
query.with(pageRequest);
return query;
}
Aggregations