List of usage examples for org.springframework.data.mongodb.core.query TextQuery setScoreFieldName
public void setScoreFieldName(String fieldName)
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}. *//*from w w w.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); }