Пример #1
0
        public List <FuseResult <T> > Search(string pattern, SearchOpts opts = null)
        {
            var searchers = PrepareSearchers(pattern);
            var search    = InternalSearch(searchers.tokenSearchers, searchers.fullSearcher);

            ComputeScore(search);

            if (_options.shouldSort)
            {
                SortSearchResults(search.results);
            }

            if (opts != null)
            {
                search.results = search.results.GetRange(0, opts.limit);
            }

            return(Format(search.results));
        }
Пример #2
0
        public static List <FuseResult <T> > Search(List <T> list, string pattern, FuseOptions <T> options, SearchOpts opts = null)
        {
            var searchers = PrepareSearchers(pattern, options);
            var search    = InternalSearch(list, searchers.tokenSearchers, searchers.fullSearcher, options);

            ComputeScore(search);

            if (options.shouldSort)
            {
                search.results.Sort((a, b) =>
                {
                    return(options.sortFn(a.score, b.score));
                });
            }

            if (opts != null)
            {
                search.results = search.results.GetRange(0, opts.limit);
            }

            return(Format(search.results, options));
        }