Exemplo n.º 1
0
        internal void Add(SearchResult other)
        {
            result.AddRange(other.result);
            nextIndex = other.nextIndex;
            searches += other.searches;

            searchTimer.CollectingTime += other.searchTimer.CollectingTime;
            searchTimer.KernelTime += other.searchTimer.KernelTime;
            searchTimer.PagingTime += other.searchTimer.PagingTime;
        }
Exemplo n.º 2
0
        private void GetResultPage(ScoreDoc[] hits, SearchParams p, SearchResult r)
        {
            var result = new List<LucObject>();
            if (hits.Length == 0)
            {
                r.result = result;
                return;
            }

            var upperBound = hits.Length;
            var index = 0;
            while (true)
            {
                Document doc = p.searcher.Doc(hits[index].Doc);
                if (p.allVersions || IsPermitted(doc, p.user, p.isCurrentUser))
                {
                    result.Add(new LucObject(doc));
                    if (result.Count == p.top)
                    {
                        index++;
                        break;
                    }
                }
                if (++index >= upperBound)
                    break;
            }
            r.nextIndex = index;
            r.result = result;
        }
Exemplo n.º 3
0
 static SearchResult()
 {
     Empty = new SearchResult(null) { searches = 0 };
 }
Exemplo n.º 4
0
        private SearchResult Search(SearchParams p)
        {
            var r = new SearchResult(p.timer);
            var t = r.searchTimer;

            t.BeginKernelTime();
            var collector = CreateCollector(p.collectorSize);
            p.searcher.Search(p.query, collector);
            t.FinishKernelTime();

            t.BeginCollectingTime();
            //var topDocs = p.useHowMany ? collector.TopDocs(p.skip, p.howMany) : collector.TopDocs(p.skip);
            TopDocs topDocs = null;
            if (this.LucQuery.SortFields.Length > 0)
            {
                topDocs = p.useHowMany ? ((TopFieldCollector)collector).TopDocs(p.skip, p.howMany) : ((TopFieldCollector)collector).TopDocs(p.skip);
            }
            else
            {
                topDocs = p.useHowMany ? ((TopScoreDocCollector)collector).TopDocs(p.skip, p.howMany) : ((TopScoreDocCollector)collector).TopDocs(p.skip);
            }
            r.totalCount = topDocs.TotalHits;
            var hits = topDocs.ScoreDocs;

            t.FinishCollectingTime();

            t.BeginPagingTime();
            GetResultPage(hits, p, r);
            t.FinishPagingTime();

            return r;
        }