see on GitHub

How to migrate Suggestions from 3.x?

Suggestion 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;
using Raven.Client.Documents;
using Raven.Client.Documents.Queries.Suggestions;

Example

3.x 4.0
SuggestionQueryResult suggestions = session
    .Query<Employee, Employees_ByFullName>()
    .Suggest(
        new SuggestionQuery
        {
            Field = "FullName",
            Term = "johne",
            Accuracy = 0.4f,
            MaxSuggestions = 5,
            Distance = StringDistanceTypes.JaroWinkler,
            Popularity = true,
        });
Dictionary<string, SuggestionResult> suggestions = session
    .Query<Employee, Employees_ByFullName>()
    .SuggestUsing(builder => builder
        .ByField("FullName", "johne")
        .WithOptions(new SuggestionOptions
        {
            Accuracy = 0.4f,
            PageSize = 5,
            Distance = StringDistanceTypes.JaroWinkler,
            SortMode = SuggestionSortMode.Popularity
        }))
    .Execute();

Remarks

Information

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