You are currently browsing legacy 3.0 version of documentation. Click here to switch to the newest 5.2 version.

We can help you with migration to the latest RavenDB

Contact Us Now
see on GitHub

Commands: Querying: How to work with Suggestion query?

To take advantage of a suggestion feature use the Suggest method from the commands.


SuggestionQueryResult Suggest(string index, SuggestionQuery suggestionQuery);
index string A name of an index to query.
suggestionQuery SuggestionQuery A suggestion query definition containing all information required to query a specified index.
Return Value
SuggestionQueryResult Result containing an array of all suggestions for executed query


// Get suggestions for 'johne' using 'FullName' field in 'Users/ByFullName' index
SuggestionQueryResult result = store
		new SuggestionQuery
				Field = "FullName",
				Term = "johne",
				MaxSuggestions = 10

Console.WriteLine("Did you mean?");

foreach (string suggestion in result.Suggestions)
	Console.WriteLine("\t{0}", suggestion);

// Did you mean?
//		john
//		jones
//		johnson