/// <summary> /// Use some heuristics to reduce the number of autocompletions that need to be sorted. /// Relies on the long tail and the max of the RankingWeights. /// </summary> /// <param name="autoCompletionList"></param> /// <returns></returns> public IEnumerable<AutoCompletion> GetTopAutoCompletions(AutoCompletionList autoCompletionList, int minQueryFrequency = 2) { TopNStructure<AutoCompletion> topNAutocompletions = new TopNStructure<AutoCompletion>(4); // Up to 4 completions suggested if (autoCompletionList.Count <= 4) { autoCompletionList.Sort(); return autoCompletionList; } foreach (AutoCompletion ac in autoCompletionList) { if (ac.RankingWeight < minQueryFrequency) continue; // Ignore; topNAutocompletions.Add(ac); } return topNAutocompletions; }