List of usage examples for org.springframework.data.mongodb.core.query TextCriteria forDefaultLanguage
public static TextCriteria forDefaultLanguage()
From source file:example.springdata.mongodb.textsearch.TextSearchRepositoryTests.java
/** * Show how to do simple matching. <br /> * Note that text search is case insensitive and will also find entries like {@literal releases}. *///from ww w . j ava 2 s . c o m @Test public void findAllBlogPostsWithRelease() { TextCriteria criteria = TextCriteria.forDefaultLanguage().matchingAny("release"); List<BlogPost> blogPosts = repo.findAllBy(criteria); printResult(blogPosts, criteria); }
From source file:example.springdata.mongodb.textsearch.TextSearchRepositoryTests.java
/** * Simple matching using negation./* w ww . j a v a2 s. c o m*/ */ @Test public void findAllBlogPostsWithReleaseButHeyIDoWantTheEngineeringStuff() { TextCriteria criteria = TextCriteria.forDefaultLanguage().matchingAny("release").notMatching("engineering"); List<BlogPost> blogPosts = repo.findAllBy(criteria); printResult(blogPosts, criteria); }
From source file:example.springdata.mongodb.textsearch.TextSearchTemplateTests.java
/** * Show how to do simple matching. Note that text search is case insensitive and will also find entries like * {@literal releases}.//from www . j av a2s. c o m */ @Test public void findAllBlogPostsWithRelease() { TextCriteria criteria = TextCriteria.forDefaultLanguage().matchingAny("release"); List<BlogPost> blogPosts = operations.find(query(criteria), BlogPost.class); printResult(blogPosts, criteria); }
From source file:example.springdata.mongodb.textsearch.TextSearchRepositoryTests.java
/** * Phrase matching looks for the whole phrase as one. *//*from w w w . j a v a 2s. com*/ @Test public void findAllBlogPostsByPhrase() { TextCriteria criteria = TextCriteria.forDefaultLanguage().matchingPhrase("release candidate"); List<BlogPost> blogPosts = repo.findAllBy(criteria); printResult(blogPosts, criteria); }
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 va 2 s . com @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); }
From source file:example.springdata.mongodb.textsearch.TextSearchRepositoryTests.java
/** * Sort by relevance relying on the value marked with {@link TextScore}. *///from ww w . java 2 s .c o m @Test public void findAllBlogPostsByPhraseSortByScore() { TextCriteria criteria = TextCriteria.forDefaultLanguage().matchingPhrase("release candidate"); List<BlogPost> blogPosts = repo.findAllByOrderByScoreDesc(criteria); printResult(blogPosts, criteria); }