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


C# IndexReader.DeleteDocument方法代码示例

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


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

示例1: 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


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