コード例 #1
0
ファイル: Searcher.cs プロジェクト: votrongdao/Corax
        public QueryResults QueryTop(Query query, int take,
            IndexingConventions.ScorerCalc score = null,
            Sorter sortBy = null)
        {
            if (take < 0)
                throw new ArgumentException("Take must be non negative");

            var qr = new QueryResults();
            var heap = new Heap<QueryMatch>(take, GenerateComparisonFunction(sortBy));
            foreach (var match in Query(query, score))
            {
                heap.Enqueue(match);
                qr.TotalResults++;
            }
            qr.Results = new QueryMatch[heap.Count];
            int pos = 0;
            while (heap.Count > 0)
            {
                qr.Results[pos++] = heap.Dequeue();
            }
            return qr;
        }
コード例 #2
0
ファイル: Searcher.cs プロジェクト: votrongdao/Corax
 public IEnumerable<QueryMatch> Query(Query query, IndexingConventions.ScorerCalc score = null, Sorter sortby = null)
 {
     query.Initialize(_index, _tx, score ?? new DefaultScorer(_index.Conventions).Score);
     return query.Execute();
 }