see on GitHub

How to migrate MoreLikeThis from 3.x?

MoreLikeThis functionality have been merged into RQL and to reflect that change the Client API have integrated this feature into the session.Query and session.Advanced.DocumentQuery. Below migration samples will focus on the session.Query - the most common and recommended way of interaction with querying capabilities on RavenDB.

Namespaces

3.x 4.0
using Raven.Abstractions.Data;
using Raven.Client.Bundles.MoreLikeThis;
using Raven.Client.Document;
using Raven.Client.Documents;
using Raven.Client.Documents.Queries.MoreLikeThis;

Example I

3.x 4.0
Article[] articles = session
    .Advanced
    .MoreLikeThis<Article>(
        "Articles/MoreLikeThis",
        null,
        new MoreLikeThisQuery
        {
            IndexName = "Articles/MoreLikeThis",
            DocumentId = "articles/1",
            Fields = new[] { "Body" }
        });
List<Article> articles = session
    .Query<Article>("Articles/MoreLikeThis")
    .MoreLikeThis(builder => builder
        .UsingDocument(x => x.Id == "articles/1")
        .WithOptions(new MoreLikeThisOptions
        {
            Fields = new[] { "Body" }
        }))
    .ToList();

Example II

3.x 4.0
Article[] articles = session
    .Advanced
    .MoreLikeThis<Article>(
        "Articles/MoreLikeThis",
        null,
        new MoreLikeThisQuery
        {
            IndexName = "Articles/MoreLikeThis",
            DocumentId = "articles/1",
            Fields = new[] { "Body" },
            AdditionalQuery = "Category:IT"
        });
List<Article> articles = session
    .Query<Article>("Articles/MoreLikeThis")
    .MoreLikeThis(builder => builder
        .UsingDocument(x => x.Id == "articles/1")
        .WithOptions(new MoreLikeThisOptions
        {
            Fields = new[] { "Body" }
        }))
    .Where(x => x.Category == "IT")
    .ToList();

Remarks

Information

You can read more about MoreLikeThis in a dedicated Client API article that can be found here.