Migration: How to Migrate Suggestions from 3.x
Suggestion functionality has been merged into RQL. To reflect this change, the Client API has integrated this feature into the session.Query
and session.Advanced.DocumentQuery
. The following migration samples will focus on the session.Query
, the most common and recommended way of interaction with querying capabilities on RavenDB.
Namespaces
3.x |
using Raven.Abstractions.Data;
using Raven.Client;
|
4.0 |
using Raven.Client.Documents;
using Raven.Client.Documents.Queries.Suggestions;
|
Example
3.x |
SuggestionQueryResult suggestions = session
.Query<Employee, Employees_ByFullName>()
.Suggest(
new SuggestionQuery
{
Field = "FullName",
Term = "johne",
Accuracy = 0.4f,
MaxSuggestions = 5,
Distance = StringDistanceTypes.JaroWinkler,
Popularity = true,
});
|
4.0 |
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();
|
Information
You can read more about Suggestions in a dedicated Client API article that can be found here.