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


C# IndexReader.TermDocs方法代码示例

本文整理汇总了C#中Transformalize.Libs.Lucene.Net.Index.IndexReader.TermDocs方法的典型用法代码示例。如果您正苦于以下问题:C# IndexReader.TermDocs方法的具体用法?C# IndexReader.TermDocs怎么用?C# IndexReader.TermDocs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Transformalize.Libs.Lucene.Net.Index.IndexReader的用法示例。


在下文中一共展示了IndexReader.TermDocs方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MatchAllScorer

			internal MatchAllScorer(MatchAllDocsQuery enclosingInstance, IndexReader reader, Similarity similarity, Weight w, byte[] norms):base(similarity)
			{
				InitBlock(enclosingInstance);
				this.termDocs = reader.TermDocs(null);
				score = w.Value;
				this.norms = norms;
			}
开发者ID:mindis,项目名称:Transformalize,代码行数:7,代码来源:MatchAllDocsQuery.cs

示例2: ApplyDeletes

		// Apply buffered delete terms, queries and docIDs to the
		// provided reader
		private bool ApplyDeletes(IndexReader reader, int docIDStart)
		{
			lock (this)
			{
				int docEnd = docIDStart + reader.MaxDoc;
				bool any = false;
				
                System.Diagnostics.Debug.Assert(CheckDeleteTerm(null));

				// Delete by term
				TermDocs docs = reader.TermDocs();
				try
				{
					foreach(KeyValuePair<Term, BufferedDeletes.Num> entry in deletesFlushed.terms)
					{
						Term term = entry.Key;
						// LUCENE-2086: we should be iterating a TreeMap,
                        // here, so terms better be in order:
                        System.Diagnostics.Debug.Assert(CheckDeleteTerm(term));
						docs.Seek(term);
						int limit = entry.Value.GetNum();
						while (docs.Next())
						{
							int docID = docs.Doc;
							if (docIDStart + docID >= limit)
								break;
							reader.DeleteDocument(docID);
							any = true;
						}
					}
				}
				finally
				{
					docs.Close();
				}
				
				// Delete by docID
				foreach(int docIdInt in deletesFlushed.docIDs)
				{
				    int docID = docIdInt;
					if (docID >= docIDStart && docID < docEnd)
					{
						reader.DeleteDocument(docID - docIDStart);
						any = true;
					}
				}
				
				// Delete by query
				IndexSearcher searcher = new IndexSearcher(reader);
				foreach(KeyValuePair<Query, int> entry in deletesFlushed.queries)
				{
					Query query = (Query) entry.Key;
					int limit = (int)entry.Value;
					Weight weight = query.Weight(searcher);
					Scorer scorer = weight.Scorer(reader, true, false);
					if (scorer != null)
					{
						while (true)
						{
							int doc = scorer.NextDoc();
							if (((long) docIDStart) + doc >= limit)
								break;
							reader.DeleteDocument(doc);
							any = true;
						}
					}
				}
				searcher.Close();
				return any;
			}
		}
开发者ID:mindis,项目名称:Transformalize,代码行数:73,代码来源:DocumentsWriter.cs

示例3: CreateValue

 protected internal override System.Object CreateValue(IndexReader reader, Entry entryKey)
 {
     System.String field = StringHelper.Intern(entryKey.field);
     int[] retArray = new int[reader.MaxDoc];
     System.String[] mterms = new System.String[reader.MaxDoc + 1];
     TermDocs termDocs = reader.TermDocs();
     TermEnum termEnum = reader.Terms(new Term(field));
     int t = 0; // current term number
     
     // an entry for documents that have no terms in this field
     // should a document with no terms be at top or bottom?
     // this puts them at the top - if it is changed, FieldDocSortedHitQueue
     // needs to change as well.
     mterms[t++] = null;
     
     try
     {
         do 
         {
             Term term = termEnum.Term;
             if (term == null || term.Field != field || t >= mterms.Length) break;
             
             // store term text
             mterms[t] = term.Text;
             
             termDocs.Seek(termEnum);
             while (termDocs.Next())
             {
                 retArray[termDocs.Doc] = t;
             }
             
             t++;
         }
         while (termEnum.Next());
     }
     finally
     {
         termDocs.Close();
         termEnum.Close();
     }
     
     if (t == 0)
     {
         // if there are no terms, make the term array
         // have a single null entry
         mterms = new System.String[1];
     }
     else if (t < mterms.Length)
     {
         // if there are less terms than documents,
         // trim off the dead array space
         System.String[] terms = new System.String[t];
         Array.Copy(mterms, 0, terms, 0, t);
         mterms = terms;
     }
     
     StringIndex value_Renamed = new StringIndex(retArray, mterms);
     return value_Renamed;
 }
开发者ID:mindis,项目名称:Transformalize,代码行数:59,代码来源:FieldCacheImpl.cs

示例4: ValueSourceScorer

 // constructor
 internal ValueSourceScorer(ValueSourceQuery enclosingInstance, Similarity similarity, IndexReader reader, ValueSourceWeight w)
     : base(similarity)
 {
     InitBlock(enclosingInstance);
     this.weight = w;
     this.qWeight = w.Value;
     // this is when/where the values are first created.
     vals = Enclosing_Instance.valSrc.GetValues(reader);
     termDocs = reader.TermDocs(null);
 }
开发者ID:mindis,项目名称:Transformalize,代码行数:11,代码来源:ValueSourceQuery.cs

示例5: Scorer

			public override Scorer Scorer(IndexReader reader, bool scoreDocsInOrder, bool topScorer)
			{
				TermDocs termDocs = reader.TermDocs(Enclosing_Instance.term);
				
				if (termDocs == null)
					return null;
				
				return new TermScorer(this, termDocs, similarity, reader.Norms(Enclosing_Instance.term.Field));
			}
开发者ID:mindis,项目名称:Transformalize,代码行数:9,代码来源:TermQuery.cs

示例6: Explain

			public override Explanation Explain(IndexReader reader, int doc)
			{
				
				ComplexExplanation result = new ComplexExplanation();
				result.Description = "weight(" + Query + " in " + doc + "), product of:";
				
				Explanation expl = new Explanation(idf, idfExp.Explain());
				
				// explain query weight
				Explanation queryExpl = new Explanation();
				queryExpl.Description = "queryWeight(" + Query + "), product of:";
				
				Explanation boostExpl = new Explanation(Enclosing_Instance.Boost, "boost");
				if (Enclosing_Instance.Boost != 1.0f)
					queryExpl.AddDetail(boostExpl);
				queryExpl.AddDetail(expl);
				
				Explanation queryNormExpl = new Explanation(queryNorm, "queryNorm");
				queryExpl.AddDetail(queryNormExpl);
				
				queryExpl.Value = boostExpl.Value * expl.Value * queryNormExpl.Value;
				
				result.AddDetail(queryExpl);
				
				// explain field weight
				System.String field = Enclosing_Instance.term.Field;
				ComplexExplanation fieldExpl = new ComplexExplanation();
				fieldExpl.Description = "fieldWeight(" + Enclosing_Instance.term + " in " + doc + "), product of:";

                Explanation tfExplanation = new Explanation();
                int tf = 0;
                TermDocs termDocs = reader.TermDocs(enclosingInstance.term);
                if (termDocs != null)
                {
                    try
                    {
                        if (termDocs.SkipTo(doc) && termDocs.Doc == doc)
                        {
                            tf = termDocs.Freq;
                        }
                    }
                    finally
                    {
                        termDocs.Close();
                    }
                    tfExplanation.Value = similarity.Tf(tf);
                    tfExplanation.Description = "tf(termFreq(" + enclosingInstance.term + ")=" + tf + ")";
                }
                else
                {
                    tfExplanation.Value = 0.0f;
                    tfExplanation.Description = "no matching term";
                }
                fieldExpl.AddDetail(tfExplanation);
				fieldExpl.AddDetail(expl);
				
				Explanation fieldNormExpl = new Explanation();
				byte[] fieldNorms = reader.Norms(field);
				float fieldNorm = fieldNorms != null?Similarity.DecodeNorm(fieldNorms[doc]):1.0f;
				fieldNormExpl.Value = fieldNorm;
				fieldNormExpl.Description = "fieldNorm(field=" + field + ", doc=" + doc + ")";
				fieldExpl.AddDetail(fieldNormExpl);

                fieldExpl.Match = tfExplanation.IsMatch;
                fieldExpl.Value = tfExplanation.Value * expl.Value * fieldNormExpl.Value;
				
				result.AddDetail(fieldExpl);
				System.Boolean? tempAux = fieldExpl.Match;
				result.Match = tempAux;
				
				// combine them
				result.Value = queryExpl.Value * fieldExpl.Value;
				
				if (queryExpl.Value == 1.0f)
					return fieldExpl;
				
				return result;
			}
开发者ID:mindis,项目名称:Transformalize,代码行数:78,代码来源:TermQuery.cs

示例7: TermDocs

 protected internal virtual TermDocs TermDocs(IndexReader reader)
 {
     return term == null ? reader.TermDocs(null):reader.TermDocs();
 }
开发者ID:mindis,项目名称:Transformalize,代码行数:4,代码来源:DirectoryReader.cs


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