public static IEnumerable <DataType> getSuggestions(string prefix) { List <DataType> suggestions = new List <DataType>(); IEnumerable <DataType> searchResults = new List <DataType>(); try { searchResults = luceneSearch.Search(prefix); } catch { return(new List <DataType>()); } int count = 0; foreach (DataType word in searchResults.Reverse <DataType>()) { count++; suggestions.Add(word); if (count == 4) { break; } } return(suggestions); }
/// <summary> /// Given a prefix or a similar word, retrieves a list of words starting from the prefix, or close to it, ordered by relevance /// </summary> /// <param name="prefix">Prefix or similar word to be processed</param> /// <returns></returns> public static List <string> getSuggestions(string prefix) { List <string> suggestions = new List <string>(); IEnumerable <DataType> searchResults = new List <DataType>(); try { searchResults = luceneSearch.Search(prefix); } catch { searchResults = new List <DataType>(); } foreach (DataType word in searchResults.Reverse <DataType>()) { suggestions.Add(word.Word); } return(suggestions); }