public class People : AbstractIndexCreationTask<Person>
{
public People()
{
Map = people => from p in people
select new
{
p.Name
};
Index(x => x.Name, FieldIndexing.Default);
Store(x => x.Name, FieldStorage.Yes);
Suggestion(x => x.Name);
}
}
private static void GetSuggestions(IDocumentSession session, string term)
{
var suggestionResult = session.Query<Person, People>()
.Suggest(new SuggestionQuery
{
Field = "Name",
Term = term,
Accuracy = 0.5f,
MaxSuggestions = 10,
Distance = StringDistanceTypes.Levenshtein
});
var suggestions = suggestionResult.Suggestions;
Console.WriteLine($"{suggestions.Length} suggestion(s) found.");
Array.ForEach(suggestions, x => Console.WriteLine($"\t{x}"));
}
private static void GetSuggestions(IDocumentSession session, string term)
{
var suggestionResult = session.Query<Person, People>()
.SuggestUsing(builder => builder.ByField("Name", term)
.WithOptions(new SuggestionOptions
{
Accuracy = 0.5f,
PageSize = 10,
Distance = StringDistanceTypes.Levenshtein
}))
.Execute();
var suggestions = suggestionResult["Name"].Suggestions;
Console.WriteLine($"{suggestions.Count} suggestion(s) found.");
suggestions.ForEach(x => Console.WriteLine($"\t{x}"));
}
session.Store(new Person { Name = "Erich Maria Remarque" });
session.Store(new Person { Name = "John Steinbeck" });
session.Store(new Person { Name = "Jerome David Salinger" });
session.Store(new Person { Name = "Fyodor Dostoevsky" });
session.Store(new Person { Name = "Ernest Hemingway" });
session.Store(new Person { Name = "Gabriel Garcia Marquez" });
GetSuggestions(session, "John Steinback");
GetSuggestions(session, "Jonh Steinbeck");
1 suggestion(s) found.
john steinbeck
1 suggestion(s) found.
john steinbeck
1 suggestion(s) found.
steinbeck
1 suggestion(s) found.
steinbeck
GetSuggestions(session, "Erich Maria Remarch");
5 suggestion(s) found.
maria
erich
remarque
marquez
garcia
--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hibernating Rhinos Ltd
Tal Weiss l Core Team Developer l Mobile:+972-54-802-4849
Office: +972-4-622-7811 l Fax: +972-153-4-622-7811l Skype: talweiss1982
RavenDB paving the way to "Data Made Simple" http://ravendb.net/
So it's a bug. OK, thank you for your quick reaction. I'll be waiting for the fix.
--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.