本文整理汇总了C#中Lucene.Net.Search.HitCollector类的典型用法代码示例。如果您正苦于以下问题:C# HitCollector类的具体用法?C# HitCollector怎么用?C# HitCollector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HitCollector类属于Lucene.Net.Search命名空间,在下文中一共展示了HitCollector类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Score
protected internal override bool Score(HitCollector c, int end)
{
Similarity similarity = GetSimilarity(); // cache sim in local
float[] normDecoder = Similarity.GetNormDecoder();
while (doc < end)
{
// for docs in window
int f = freqs[pointer];
float score = f < SCORE_CACHE_SIZE ? scoreCache[f] : similarity.Tf(f) * weightValue; // cache miss
score *= normDecoder[norms[doc] & 0xFF]; // normalize for field
c.Collect(doc, score); // 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: TimeLimitedCollector
/// <summary> Create a TimeLimitedCollector wrapper over another HitCollector with a specified timeout.</summary>
/// <param name="hc">the wrapped HitCollector
/// </param>
/// <param name="timeAllowed">max time allowed for collecting hits after which {@link TimeExceededException} is thrown
/// </param>
public TimeLimitedCollector(HitCollector hc, long timeAllowed)
{
InitBlock();
this.hc = hc;
t0 = TIMER_THREAD.GetMilliseconds();
this.timeout = t0 + timeAllowed;
}
示例3: Score
/// <summary>Scores and collects all matching documents.</summary>
/// <param name="hc">The collector to which all matching documents are passed through
/// {@link HitCollector#Collect(int, float)}.
/// <br>When this method is used the {@link #Explain(int)} method should not be used.
/// </param>
public virtual void Score(HitCollector hc)
{
while (Next())
{
hc.Collect(Doc(), Score());
}
}
示例4: SubScorer
public SubScorer(Scorer scorer, bool required, bool prohibited, HitCollector collector, SubScorer next)
{
this.scorer = scorer;
this.done = !scorer.Next();
this.required = required;
this.prohibited = prohibited;
this.collector = collector;
this.next = next;
}
示例5: Score
/// <summary>Expert: Collects matching documents in a range. Hook for optimization.
/// Note that {@link #Next()} must be called once before this method is called
/// for the first time.
/// </summary>
/// <param name="hc">The collector to which all matching documents are passed through
/// {@link HitCollector#Collect(int, float)}.
/// </param>
/// <param name="max">Do not score documents past this.
/// </param>
/// <returns> true if more matching documents may remain.
/// </returns>
protected internal virtual bool Score(HitCollector hc, int max)
{
while (Doc() < max)
{
hc.Collect(Doc(), Score());
if (!Next())
return false;
}
return true;
}
示例6: Search
public virtual void Search(Query query, HitCollector results)
{
Search(CreateWeight(query), null, new HitCollectorWrapper(results));
}
示例7: HitCollectorWrapper
public HitCollectorWrapper(HitCollector collector)
{
this.collector = collector;
}
示例8: 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);
}
}
}
}
示例9: Search
/// <summary>Lower-level search API.
///
/// <p>{@link HitCollector#Collect(int,float)} is called for every non-zero
/// scoring document.
/// <br>HitCollector-based access to remote indexes is discouraged.
///
/// <p>Applications should only use this if they need <i>all</i> of the
/// matching documents. The high-level search API ({@link
/// Searcher#Search(Query)}) is usually more efficient, as it skips
/// non-high-scoring hits.
///
/// </summary>
/// <param name="query">to match documents
/// </param>
/// <param name="filter">if non-null, a bitset used to eliminate some documents
/// </param>
/// <param name="results">to receive hits
/// </param>
/// <throws> BooleanQuery.TooManyClauses </throws>
public virtual void Search(Query query, Filter filter, HitCollector results)
{
Search(CreateWeight(query), filter, results);
}
示例10: Search
public virtual void Search(Weight weight, Filter filter, HitCollector results)
{
local.Search(weight, filter, results);
}
示例11: Score
protected internal virtual bool Score(HitCollector hc, int max)
{
return Score(new HitCollectorWrapper(hc), max, DocID());
}
示例12: Score
public override void Score(HitCollector hc)
{
Next();
Score(hc, System.Int32.MaxValue);
}
示例13: Score
/// <summary>Expert: Collects matching documents in a range.
/// <br>Note that {@link #Next()} must be called once before this method is
/// called for the first time.
/// </summary>
/// <param name="hc">The collector to which all matching documents are passed through
/// {@link HitCollector#Collect(int, float)}.
/// </param>
/// <param name="max">Do not score documents past this.
/// </param>
/// <returns> true if more matching documents may remain.
/// </returns>
protected internal override bool Score(HitCollector hc, int max)
{
// null pointer exception when Next() was not called before:
int docNr = countingSumScorer.Doc();
while (docNr < max)
{
hc.Collect(docNr, Score());
if (!countingSumScorer.Next())
{
return false;
}
docNr = countingSumScorer.Doc();
}
return true;
}
示例14: Score
protected internal override bool Score(HitCollector hc, int max)
{
if (coordFactors == null)
ComputeCoordFactors();
bool more;
Bucket tmp;
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;
}
hc.Collect(current.doc, current.score * coordFactors[current.coord]);
}
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.done)
{
sub.done = !sub.scorer.Score(sub.collector, end);
if (!sub.done)
more = true;
}
}
current = bucketTable.first;
}
while (current != null || more);
return false;
}
示例15: Search
public override void Search(Query query, Filter filter, HitCollector results)
{
CheckExplanations(query);
base.Search(query, filter, results);
}