Example #1
0
        public static SearchIndex <TType> Build <TType>(IEnumerable <TType> source, SearchIndexOptions <TType> options)
        {
            if (!options.Properties.Any())
            {
                throw new Exception($"No properties specified to index");
            }

            var wordFrequency = new Dictionary <string, int>();
            var index         = new SearchIndex <TType>
            {
                Options = options,
                Source  = source.Select(c => IndexItem(c, options, wordFrequency)).ToList()
            };

            // Index the top 1% of common words to give low scores too
            var possibleCommonWords = wordFrequency.Where(w => w.Value > 2);

            index.CommonWords = possibleCommonWords.OrderByDescending(c => c.Value).Take(possibleCommonWords.Count() / 100).Select(w => w.Key).ToArray();

            return(index);
        }
Example #2
0
 public static SearchIndex <TType> ReBuild <TType>(SearchIndex <TType> original, ObservableCollection <TType> source, SearchIndexOptions <TType> options)
 {
     return(original);
 }