You are currently browsing legacy 3.0 version of documentation. Click here to switch to the newest 5.1 version.
Commands: Querying: How to work with MoreLikeThis query?
To find similar or related documents use the MoreLikeThis method from the commands.
Syntax
MultiLoadResult MoreLikeThis(MoreLikeThisQuery query);
Parameters | ||
---|---|---|
query | MoreLikeThisQuery | A more like this query definition that will be executed |
Return Value | |
---|---|
MultiLoadResult | Instance of MultiLoadResult containing query Results and Includes (if any). |
Example I
// Search for similar documents to 'articles/1'
// using 'Articles/MoreLikeThis' index and search only field 'Body'
MultiLoadResult result = store
.DatabaseCommands
.MoreLikeThis(
new MoreLikeThisQuery
{
IndexName = "Articles/MoreLikeThis",
DocumentId = "articles/1",
Fields = new[] { "Body" }
});
Example II
// Search for similar documents to 'articles/1'
// using 'Articles/MoreLikeThis' index and search only field 'Body'
// where article category is 'IT'
MultiLoadResult result = store
.DatabaseCommands
.MoreLikeThis(
new MoreLikeThisQuery
{
IndexName = "Articles/MoreLikeThis",
DocumentId = "articles/1",
Fields = new[] { "Body" },
AdditionalQuery = "Category:IT"
});