本文整理汇总了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;
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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);
}
示例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());
}
示例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);
}
示例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);
}
示例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;
}
}
}
示例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);
}
}
}
}
示例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;
}
}
}
}