List of usage examples for org.springframework.data.mongodb.core.query TextQuery sortByScore
boolean sortByScore
To view the source code for org.springframework.data.mongodb.core.query TextQuery sortByScore.
Click Source Link
From source file:example.springdata.mongodb.textsearch.TextSearchTemplateTests.java
/** * Sort by relevance relying on the value marked with {@link org.springframework.data.mongodb.core.mapping.TextScore}. *///w ww. j a v a 2s . c o m @Test public void findAllBlogPostsByPhraseSortByScore() { TextCriteria criteria = TextCriteria.forDefaultLanguage().matchingPhrase("release"); TextQuery query = new TextQuery(criteria); query.setScoreFieldName("score"); query.sortByScore(); List<BlogPost> blogPosts = operations.find(query, BlogPost.class); printResult(blogPosts, criteria); }