本文整理汇总了C#中Transformalize.Libs.Lucene.Net.Index.IndexReader.DocFreq方法的典型用法代码示例。如果您正苦于以下问题:C# IndexReader.DocFreq方法的具体用法?C# IndexReader.DocFreq怎么用?C# IndexReader.DocFreq使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Transformalize.Libs.Lucene.Net.Index.IndexReader
的用法示例。
在下文中一共展示了IndexReader.DocFreq方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Rewrite
public override Query Rewrite(IndexReader reader, MultiTermQuery query)
{
// Get the enum and start visiting terms. If we
// exhaust the enum before hitting either of the
// cutoffs, we use ConstantBooleanQueryRewrite; else,
// ConstantFilterRewrite:
ICollection<Term> pendingTerms = new List<Term>();
int docCountCutoff = (int) ((docCountPercent / 100.0) * reader.MaxDoc);
int termCountLimit = System.Math.Min(BooleanQuery.MaxClauseCount, termCountCutoff);
int docVisitCount = 0;
FilteredTermEnum enumerator = query.GetEnum(reader);
try
{
while (true)
{
Term t = enumerator.Term;
if (t != null)
{
pendingTerms.Add(t);
// Loading the TermInfo from the terms dict here
// should not be costly, because 1) the
// query/filter will load the TermInfo when it
// runs, and 2) the terms dict has a cache:
docVisitCount += reader.DocFreq(t);
}
if (pendingTerms.Count >= termCountLimit || docVisitCount >= docCountCutoff)
{
// Too many terms -- make a filter.
Query result = new ConstantScoreQuery(new MultiTermQueryWrapperFilter<MultiTermQuery>(query));
result.Boost = query.Boost;
return result;
}
else if (!enumerator.Next())
{
// Enumeration is done, and we hit a small
// enough number of terms & docs -- just make a
// BooleanQuery, now
BooleanQuery bq = new BooleanQuery(true);
foreach(Term term in pendingTerms)
{
TermQuery tq = new TermQuery(term);
bq.Add(tq, Occur.SHOULD);
}
// Strip scores
Query result = new ConstantScoreQuery(new QueryWrapperFilter(bq));
result.Boost = query.Boost;
query.IncTotalNumberOfTerms(pendingTerms.Count);
return result;
}
}
}
finally
{
enumerator.Close();
}
}