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


C# IndexReader.DocFreq方法代码示例

本文整理汇总了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();
				}
			}
开发者ID:mindis,项目名称:Transformalize,代码行数:58,代码来源:MultiTermQuery.cs


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