public Execute ( string q ) : SuggestionCollection | ||
q | string | The query string to execute. See
/// |
Результат | SuggestionCollection |
public JsonResult Autocomplete(string query) { var search = new Suggest(new Settings("www.crownpeak.com")); var searcher = search.Execute(query); if (searcher.Count > 0) { return Json(searcher[0].Options.Select(o => new { Value = o, Label = o }), JsonRequestBehavior.AllowGet); } return null; }
public static string[] GetCompletionList(string prefixText, int count) { List<string> results = new List<string>(); var autocompleter = new Suggest(new Settings(COLLECTION)); var searchResults = autocompleter.Execute(prefixText); foreach (var suggestion in (IEnumerable<Suggestion>)searchResults) { foreach (var option in suggestion.Options) { results.Add(option); if (results.Count >= count) break; } if (results.Count >= count) break; } return results.ToArray(); }