By browsing on this website you are agreeing to our 'Terms & Conditions' and the 'Privacy Policy' in regards to your rights and personal data handling.
// Search for similar articles to 'articles/1'
// using 'Articles/MoreLikeThis' index and search only field 'body'
MoreLikeThisOptions options = new MoreLikeThisOptions();
options.setFields(new String[]{ "body" });
List<Article> articles = session
.query(Article.class, Query.index("Articles/MoreLikeThis"))
.moreLikeThis(builder -> builder
.usingDocument(x -> x.whereEquals("id()", "articles/1"))
.withOptions(options))
.toList();
from index 'Articles/MoreLikeThis'
where morelikethis(id() = 'articles/1', '{ "Fields" : [ "body" ] }')
// Search for similar articles to 'articles/1'
// using 'Articles/MoreLikeThis' index and search only field 'body'
// where article category is 'IT'
MoreLikeThisOptions options = new MoreLikeThisOptions();
options.setFields(new String[]{ "body" });
List<Article> articles = session
.query(Article.class, Query.index("Articles/MoreLikeThis"))
.moreLikeThis(builder -> builder
.usingDocument(x -> x.whereEquals("id()", "articles/1"))
.withOptions(options))
.whereEquals("category", "IT")
.toList();
from index 'Articles/MoreLikeThis'
where morelikethis(id() = 'articles/1', '{ "Fields" : [ "body" ] }') and category == 'IT'