本文整理汇总了C#中Lucene.Net.Search.Collector.Collect方法的典型用法代码示例。如果您正苦于以下问题:C# Collector.Collect方法的具体用法?C# Collector.Collect怎么用?C# Collector.Collect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lucene.Net.Search.Collector
的用法示例。
在下文中一共展示了Collector.Collect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Score
// firstDocID is ignored since nextDoc() sets 'doc'
public /*protected internal*/ override bool Score(Collector c, int end, int firstDocID)
{
c.SetScorer(this);
while (doc < end)
{
// for docs in window
c.Collect(doc); // collect score
if (++pointer >= pointerMax)
{
pointerMax = termDocs.Read(docs, freqs); // refill buffers
if (pointerMax != 0)
{
pointer = 0;
}
else
{
termDocs.Close(); // close stream
doc = System.Int32.MaxValue; // set to sentinel value
return false;
}
}
doc = docs[pointer];
}
return true;
}
示例2: Score
/// <summary>Scores and collects all matching documents.</summary>
/// <param name="collector">The collector to which all matching documents are passed.
/// <br/>When this method is used the {@link #Explain(int)} method should not be used.
/// </param>
public virtual void Score(Collector collector)
{
collector.SetScorer(this);
int doc;
while ((doc = NextDoc()) != NO_MORE_DOCS)
{
collector.Collect(doc);
}
}
示例3: Score
public /*protected internal*/ override bool Score(Collector collector, int max, int firstDocID)
{
doc = firstDocID;
collector.SetScorer(this);
while (doc < max)
{
collector.Collect(doc);
doc = countingSumScorer.NextDoc();
}
return doc != NO_MORE_DOCS;
}
示例4: Score
public override bool Score(Collector collector, int max)
{
collector.Scorer = new FakeScorer();
collector.Collect(0);
return false;
}
示例5: SearchWithFilter
private void SearchWithFilter(IndexReader reader, Weight weight, Scorer scorer, Collector collector)
{
if (scorer == null)
return;
scorer.DocID();
DocIdSetIterator docIdSetIterator = scorer;
if (docIdSetIterator == null)
return;
int target = docIdSetIterator.NextDoc();
int num = target;
// 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 && !((BloclGroupingCollector) collector).GroupLimitReached)
{
collector.Collect(num);
num = docIdSetIterator.NextDoc();
//target = docIdSetIterator.NextDoc();
//num = scorer.Advance(target);
}
else
break;
}
}
示例6: Score
/// <summary>Expert: Collects matching documents in a range. Hook for optimization.
/// Note that <see cref="Next()" /> must be called once before this method is called
/// for the first time.
/// </summary>
/// <param name="collector">The collector to which all matching documents are passed through.
/// </param>
/// <param name="max">Do not score documents past this.
/// </param>
/// <param name="firstDocID"></param>
/// <returns> true if more matching documents may remain.
/// </returns>
public /*protected internal*/ override bool Score(Collector collector, int max, int firstDocID)
{
// firstDocID is ignored since nextDoc() sets 'currentDoc'
collector.SetScorer(this);
while (currentDoc < max)
{
collector.Collect(currentDoc);
if (NextDoc() == NO_MORE_DOCS)
{
return false;
}
}
return true;
}
示例7: SearchWithScorer
private void SearchWithScorer(IndexReader reader, Weight weight, Scorer scorer, Collector collector)
{
if (scorer == null)
return;
scorer.DocID();
int num = scorer.NextDoc(); ;
collector.SetScorer(scorer);
while (true)
{
if (num != DocIdSetIterator.NO_MORE_DOCS && !((GroupCollector)collector).GroupLimitReached)
{
collector.Collect(num);
num = scorer.NextDoc();
}
else
break;
}
}
示例8: 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;
}
}
示例9: Replay
public override void Replay(Collector other)
{
ReplayInit(other);
int curUpto = 0;
int curBase = 0;
int chunkUpto = 0;
CurDocs = EMPTY_INT_ARRAY;
foreach (SegStart seg in CachedSegs)
{
other.NextReader = seg.ReaderContext;
other.Scorer = CachedScorer;
while (curBase + curUpto < seg.End)
{
if (curUpto == CurDocs.Length)
{
curBase += CurDocs.Length;
CurDocs = CachedDocs[chunkUpto];
CurScores = CachedScores[chunkUpto];
chunkUpto++;
curUpto = 0;
}
CachedScorer.Score_Renamed = CurScores[curUpto];
CachedScorer.Doc = CurDocs[curUpto];
other.Collect(CurDocs[curUpto++]);
}
}
}
示例10: Score
public override bool Score(Collector collector, int max)
{
FakeScorer fakeScorer = new FakeScorer();
collector.Scorer = fakeScorer;
if (_doc == -1)
{
_doc = NextDocOutOfOrder();
}
while (_doc < max)
{
fakeScorer.doc = _doc;
fakeScorer._score = outerInstance._scores[outerInstance._ords[_scoreUpto]];
collector.Collect(_doc);
_doc = NextDocOutOfOrder();
}
return _doc != DocIdSetIterator.NO_MORE_DOCS;
}
示例11: ScoreRange
internal static bool ScoreRange(Collector collector, Scorer scorer, int currentDoc, int end)
{
while (currentDoc < end)
{
collector.Collect(currentDoc);
currentDoc = scorer.NextDoc();
}
return currentDoc != DocIdSetIterator.NO_MORE_DOCS;
}
示例12: ScoreAll
internal static void ScoreAll(Collector collector, Scorer scorer)
{
int doc;
while ((doc = scorer.NextDoc()) != DocIdSetIterator.NO_MORE_DOCS)
{
collector.Collect(doc);
}
}
示例13: Score
public override bool Score(Collector collector, int max)
{
bool more;
Bucket tmp;
FakeScorer fs = new FakeScorer();
// The internal loop will set the score and doc before calling collect.
collector.Scorer = fs;
do
{
bucketTable.First = null;
while (Current != null) // more queued
{
// check prohibited & required
if ((Current.Bits & PROHIBITED_MASK) == 0)
{
// TODO: re-enable this if BQ ever sends us required
// clauses
//&& (current.bits & requiredMask) == requiredMask) {
// NOTE: Lucene always passes max =
// Integer.MAX_VALUE today, because we never embed
// a BooleanScorer inside another (even though
// that should work)... but in theory an outside
// app could pass a different max so we must check
// it:
if (Current.Doc >= max)
{
tmp = Current;
Current = Current.Next;
tmp.Next = bucketTable.First;
bucketTable.First = tmp;
continue;
}
if (Current.Coord >= MinNrShouldMatch)
{
fs.score = (float)(Current.Score * CoordFactors[Current.Coord]);
fs.doc = Current.Doc;
fs.freq = Current.Coord;
collector.Collect(Current.Doc);
}
}
Current = Current.Next; // pop the queue
}
if (bucketTable.First != null)
{
Current = bucketTable.First;
bucketTable.First = Current.Next;
return true;
}
// refill the queue
more = false;
End += BucketTable.SIZE;
for (SubScorer sub = Scorers; sub != null; sub = sub.Next)
{
if (sub.More)
{
sub.More = sub.Scorer.Score(sub.Collector, End);
more |= sub.More;
}
}
Current = bucketTable.First;
} while (Current != null || more);
return false;
}
示例14: Score
// firstDocID is ignored since nextDoc() initializes 'current'
public /*protected internal*/ override bool Score(Collector collector, int max, int firstDocID)
{
bool more;
Bucket tmp;
BucketScorer bs = new BucketScorer();
// The internal loop will set the score and doc before calling collect.
collector.SetScorer(bs);
do
{
bucketTable.first = null;
while (current != null)
{
// more queued
// check prohibited & required
if ((current.bits & prohibitedMask) == 0 && (current.bits & requiredMask) == requiredMask)
{
if (current.doc >= max)
{
tmp = current;
current = current.next;
tmp.next = bucketTable.first;
bucketTable.first = tmp;
continue;
}
if (current.coord >= minNrShouldMatch)
{
bs.score = current.score * coordFactors[current.coord];
bs.doc = current.doc;
collector.Collect(current.doc);
}
}
current = current.next; // pop the queue
}
if (bucketTable.first != null)
{
current = bucketTable.first;
bucketTable.first = current.next;
return true;
}
// refill the queue
more = false;
end += BucketTable.SIZE;
for (SubScorer sub = scorers; sub != null; sub = sub.next)
{
int subScorerDocID = sub.scorer.DocID();
if (subScorerDocID != NO_MORE_DOCS)
{
more |= sub.scorer.Score(sub.collector, end, subScorerDocID);
}
}
current = bucketTable.first;
}
while (current != null || more);
return false;
}
示例15: 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;
}
}
}