当前位置: 首页>>代码示例>>C#>>正文


C# Weight.Scorer方法代码示例

本文整理汇总了C#中Lucene.Net.Search.Weight.Scorer方法的典型用法代码示例。如果您正苦于以下问题:C# Weight.Scorer方法的具体用法?C# Weight.Scorer怎么用?C# Weight.Scorer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Lucene.Net.Search.Weight的用法示例。


在下文中一共展示了Weight.Scorer方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SearchWithFilter

        private void SearchWithFilter(IndexReader reader, Weight weight, Filter filter, Collector collector)
        {
            DocIdSet docIdSet = filter.GetDocIdSet(reader);
            if (docIdSet == null)
                return;
            Scorer scorer = weight.Scorer(reader, true, false);
            if (scorer == null)
                return;
            scorer.DocID();

            DocIdSetIterator docIdSetIterator = docIdSet.Iterator();
            if (docIdSetIterator == null)
                return;
            int target = docIdSetIterator.NextDoc();
            int num = scorer.Advance(target);
            collector.SetScorer(scorer);
            while (true)
            {
                while (num != target)
                {
                    if (num > target)
                        target = docIdSetIterator.Advance(num);
                    else
                        num = scorer.Advance(target);
                }
                if (num != DocIdSetIterator.NO_MORE_DOCS && !((GroupCollector)collector).GroupLimitReached)
                {
                    collector.Collect(num);
                    target = docIdSetIterator.NextDoc();
                    num = scorer.Advance(target);
                }
                else
                    break;
            }
        }
开发者ID:NHSChoices,项目名称:location-service,代码行数:35,代码来源:GroupedIndexSearcher.cs

示例2: Search

 public override void Search(Weight weight, Filter filter, Collector collector)
 {
     if (filter == null)
     {
         for (int index = 0; index < this.subReaders.Length; ++index)
         {
             collector.SetNextReader(this.subReaders[index], this.docStarts[index]);
             Scorer scorer = weight.Scorer(this.subReaders[index], !collector.AcceptsDocsOutOfOrder, true);
             if (scorer != null)
                 this.SearchWithScorer(this.subReaders[index], weight, scorer, collector);
         }
     }
     else
     {
         for (int index = 0; index < this.subReaders.Length; ++index)
         {
             collector.SetNextReader(this.subReaders[index], this.docStarts[index]);
             this.SearchWithFilter(this.subReaders[index], weight, filter, collector);
         }
     }
 }
开发者ID:NHSChoices,项目名称:location-service,代码行数:21,代码来源:GroupedIndexSearcher.cs

示例3: SearchWithFilter

        private void SearchWithFilter(IndexReader reader, Weight weight, Filter filter, Collector collector)
        {
            System.Diagnostics.Debug.Assert(filter != null);

            Scorer scorer = weight.Scorer(reader, true, false);
            if (scorer == null)
            {
                return ;
            }

            int docID = scorer.DocID();
            System.Diagnostics.Debug.Assert(docID == - 1 || docID == DocIdSetIterator.NO_MORE_DOCS);

            // CHECKME: use ConjunctionScorer here?
            DocIdSet filterDocIdSet = filter.GetDocIdSet(reader);
            if (filterDocIdSet == null)
            {
                // this means the filter does not accept any documents.
                return ;
            }

            DocIdSetIterator filterIter = filterDocIdSet.Iterator();
            if (filterIter == null)
            {
                // this means the filter does not accept any documents.
                return ;
            }
            int filterDoc = filterIter.NextDoc();
            int scorerDoc = scorer.Advance(filterDoc);

            collector.SetScorer(scorer);
            while (true)
            {
                if (scorerDoc == filterDoc)
                {
                    // Check if scorer has exhausted, only before collecting.
                    if (scorerDoc == DocIdSetIterator.NO_MORE_DOCS)
                    {
                        break;
                    }
                    collector.Collect(scorerDoc);
                    filterDoc = filterIter.NextDoc();
                    scorerDoc = scorer.Advance(filterDoc);
                }
                else if (scorerDoc > filterDoc)
                {
                    filterDoc = filterIter.Advance(scorerDoc);
                }
                else
                {
                    scorerDoc = scorer.Advance(filterDoc);
                }
            }
        }
开发者ID:sinsay,项目名称:SSE,代码行数:54,代码来源:IndexSearcher.cs

示例4: Search

 public override void Search(Weight weight, Filter filter, Collector collector)
 {
     if (filter == null)
     {
         for (int i = 0; i < subReaders.Length; i++)
         {
             // search each subreader
             collector.SetNextReader(subReaders[i], docStarts[i]);
             Scorer scorer = weight.Scorer(subReaders[i], !collector.AcceptsDocsOutOfOrder(), true);
             if (scorer != null)
             {
                 scorer.Score(collector);
             }
         }
     }
     else
     {
         for (int i = 0; i < subReaders.Length; i++)
         {
             // search each subreader
             collector.SetNextReader(subReaders[i], docStarts[i]);
             SearchWithFilter(subReaders[i], weight, filter, collector);
         }
     }
 }
开发者ID:sinsay,项目名称:SSE,代码行数:25,代码来源:IndexSearcher.cs

示例5: Search

        // inherit javadoc
        public override void Search(Weight weight, Filter filter, HitCollector results)
        {
            HitCollector collector = results;
            if (filter != null)
            {
                System.Collections.BitArray bits = filter.Bits(reader);
                collector = new AnonymousClassHitCollector(bits, results, this);
            }

            Scorer scorer = weight.Scorer(reader);
            if (scorer == null)
                return ;
            scorer.Score(collector);
        }
开发者ID:karino2,项目名称:wikipediaconv,代码行数:15,代码来源:IndexSearcher.cs

示例6: Search

		// inherit javadoc
		public override TopFieldDocs Search(Weight weight, Filter filter, int nDocs, Sort sort)
		{
			Scorer scorer = weight.Scorer(reader);
			if (scorer == null)
				return new TopFieldDocs(0, new ScoreDoc[0], sort.fields, System.Single.NegativeInfinity);
			
			System.Collections.BitArray bits = filter != null ? filter.Bits(reader) : null;
			FieldSortedHitQueue hq = new FieldSortedHitQueue(reader, sort.fields, nDocs);
			int[] totalHits = new int[1];
			scorer.Score(new AnonymousClassHitCollector1(bits, totalHits, hq, this));
			
			ScoreDoc[] scoreDocs = new ScoreDoc[hq.Size()];
			for (int i = hq.Size() - 1; i >= 0; i--)
			// put docs in array
				scoreDocs[i] = hq.FillFields((FieldDoc) hq.Pop());
			
			return new TopFieldDocs(totalHits[0], scoreDocs, hq.GetFields(), hq.GetMaxScore());
		}
开发者ID:ArsenShnurkov,项目名称:beagle-1,代码行数:19,代码来源:IndexSearcher.cs

示例7: FilteredBulkScorer

 public override BulkScorer FilteredBulkScorer(AtomicReaderContext context, Weight weight, bool scoreDocsInOrder, DocIdSet docIdSet) // ignored (we always top-score in order)
 {
     Bits filterAcceptDocs = docIdSet.GetBits();
     if (filterAcceptDocs == null)
     {
         // Filter does not provide random-access Bits; we
         // must fallback to leapfrog:
         return LEAP_FROG_QUERY_FIRST_STRATEGY.FilteredBulkScorer(context, weight, scoreDocsInOrder, docIdSet);
     }
     Scorer scorer = weight.Scorer(context, null);
     return scorer == null ? null : new QueryFirstBulkScorer(scorer, filterAcceptDocs);
 }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:12,代码来源:FilteredQuery.cs

示例8: FilteredScorer

 public override Scorer FilteredScorer(AtomicReaderContext context, Weight weight, DocIdSet docIdSet)
 {
     Bits filterAcceptDocs = docIdSet.GetBits();
     if (filterAcceptDocs == null)
     {
         // Filter does not provide random-access Bits; we
         // must fallback to leapfrog:
         return LEAP_FROG_QUERY_FIRST_STRATEGY.FilteredScorer(context, weight, docIdSet);
     }
     Scorer scorer = weight.Scorer(context, null);
     return scorer == null ? null : new QueryFirstScorer(weight, filterAcceptDocs, scorer);
 }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:12,代码来源:FilteredQuery.cs

示例9: Search

        public override void Search(Weight weight, Filter filter, Collector results)
        {
            IndexReader reader = IndexReader;

            Scorer scorer = weight.Scorer(reader, true, false);

            if (scorer == null)
            {
                return;
            }

            results.SetScorer(scorer);
            results.SetNextReader(reader, 0);

            FacetValidator validator = CreateFacetValidator();
            int target = 0;
            bool more;

            if (filter == null)
            {
                more = scorer.NextDoc()!=DocIdSetIterator.NO_MORE_DOCS;
                while (more)
                {
                    target = scorer.DocID();
                    if (validator.Validate(target))
                    {
                        results.Collect(target);
                        more = scorer.NextDoc()!=DocIdSetIterator.NO_MORE_DOCS;
                    }
                    else
                    {
                        target = validator.NextTarget;
                        more = scorer.Advance(target) != DocIdSetIterator.NO_MORE_DOCS;
                    }
                }
                return;
            }

            DocIdSetIterator filterDocIdIterator = filter.GetDocIdSet(reader).Iterator(); // CHECKME: use ConjunctionScorer here?

            target = filterDocIdIterator.NextDoc();
            if (target == DocIdSetIterator.NO_MORE_DOCS)
            {
                return;
            }

            int doc = -1;
            while (true)
            {
                if (doc < target)
                {
                    doc = scorer.Advance(target);
                    if (doc == DocIdSetIterator.NO_MORE_DOCS)
                    {
                        break;
                    }
                }

                if (doc == target) // permitted by filter
                {
                    if (validator.Validate(doc))
                    {
                        results.Collect(doc);

                        target = filterDocIdIterator.NextDoc();
                        if (target == DocIdSetIterator.NO_MORE_DOCS)
                        {
                            break;
                        }
                        else
                        {
                            continue;
                        }
                    }
                    else
                    {
                        // skip to the next possible docid
                        target = validator.NextTarget;
                    }
                }
                else // doc > target
                {
                    target = doc;
                }

                target = filterDocIdIterator.Advance(target);
                if (target == DocIdSetIterator.NO_MORE_DOCS)
                {
                    break;
                }
            }
        }
开发者ID:NightOwl888,项目名称:Bobo-Browse.Net,代码行数:92,代码来源:BoboSearcher2.cs

示例10: Search

        // inherit javadoc
        public override void Search(Weight weight, Filter filter, HitCollector results)
        {
            Scorer scorer = weight.Scorer(reader);
            if (scorer == null)
                return;

            if (filter == null)
            {
                scorer.Score(results);
                return;
            }

            DocIdSetIterator filterDocIdIterator = filter.GetDocIdSet(reader).Iterator(); // CHECKME: use ConjunctionScorer here?

            bool more = filterDocIdIterator.Next() && scorer.SkipTo(filterDocIdIterator.Doc());

            while (more)
            {
                int filterDocId = filterDocIdIterator.Doc();
                if (filterDocId > scorer.Doc() && !scorer.SkipTo(filterDocId))
                {
                    more = false;
                }
                else
                {
                    int scorerDocId = scorer.Doc();
                    if (scorerDocId == filterDocId) // permitted by filter
                    {
                        results.Collect(scorerDocId, scorer.Score());
                        more = filterDocIdIterator.Next();
                    }
                    else
                    {
                        more = filterDocIdIterator.SkipTo(scorerDocId);
                    }
                }
            }
        }
开发者ID:cqm0609,项目名称:lucene-file-finder,代码行数:39,代码来源:IndexSearcher.cs

示例11: Search

        public override void Search(Weight weight, Filter filter, Collector results)
        {
            IndexReader reader = IndexReader;

            bool doValidate = false;
            FacetHitCollector[] facetCollectors = this.facetCollectors.ToArray();
            foreach (FacetHitCollector facetCollector in facetCollectors)
            {
                if (facetCollector.PostDocIDSetIterator != null)
                {
                    doValidate = true;
                    break;
                }
            }

            Scorer scorer = weight.Scorer(reader, true, false);
            if (scorer == null)
            {
                return;
            }

            results.SetScorer(scorer);

            if (filter == null)
            {
                while (scorer.NextDoc()!=DocIdSetIterator.NO_MORE_DOCS)
                {
                    int doc = scorer.DocID();
                    if (validateAndIncrement(doc, facetCollectors, doValidate))
                    {
                        results.Collect(doc);
                    }
                }
                return;
            }

            DocIdSetIterator filterDocIdIterator = filter.GetDocIdSet(reader).Iterator(); // CHECKME: use ConjunctionScorer here?

            bool more = filterDocIdIterator.NextDoc() != DocIdSetIterator.NO_MORE_DOCS && scorer.Advance(filterDocIdIterator.DocID()) != DocIdSetIterator.NO_MORE_DOCS;

            while (more)
            {
                int filterDocId = filterDocIdIterator.DocID();
                if (filterDocId > scorer.DocID() && scorer.Advance(filterDocId)==DocIdSetIterator.NO_MORE_DOCS)
                {
                    more = false;
                }
                else
                {
                    int scorerDocId = scorer.DocID();
                    if (scorerDocId == filterDocId) // permitted by filter
                    {
                        if (validateAndIncrement(scorerDocId, facetCollectors, doValidate))
                        {
                            results.Collect(scorerDocId);
                        }
                        more = filterDocIdIterator.NextDoc()!=DocIdSetIterator.NO_MORE_DOCS;
                    }
                    else
                    {
                        more = filterDocIdIterator.Advance(scorerDocId) != DocIdSetIterator.NO_MORE_DOCS;
                    }
                }
            }
        }
开发者ID:NightOwl888,项目名称:Bobo-Browse.Net,代码行数:65,代码来源:BoboSearcher.cs


注:本文中的Lucene.Net.Search.Weight.Scorer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。