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


C# IndexWriter.ExpungeDeletes方法代码示例

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


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

示例1: TestExpungeDeletes

 public virtual void  TestExpungeDeletes()
 {
     Directory dir = new MockRAMDirectory();
     IndexWriter w = new IndexWriter(dir, new WhitespaceAnalyzer(), IndexWriter.MaxFieldLength.LIMITED);
     Document doc = new Document();
     doc.Add(new Field("field", "a b c", Field.Store.NO, Field.Index.ANALYZED));
     Field id = new Field("id", "", Field.Store.NO, Field.Index.NOT_ANALYZED);
     doc.Add(id);
     id.SetValue("0");
     w.AddDocument(doc);
     id.SetValue("1");
     w.AddDocument(doc);
     w.DeleteDocuments(new Term("id", "0"));
     
     IndexReader r = w.GetReader();
     w.ExpungeDeletes();
     w.Close();
     r.Close();
     r = IndexReader.Open(dir, true);
     Assert.AreEqual(1, r.NumDocs());
     Assert.IsFalse(r.HasDeletions);
     r.Close();
     dir.Close();
 }
开发者ID:Nangal,项目名称:lucene.net,代码行数:24,代码来源:TestIndexWriterReader.cs

示例2: TestExpungeDeletes3

		public virtual void  TestExpungeDeletes3()
		{
			Directory dir = new MockRAMDirectory();
			IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(), IndexWriter.MaxFieldLength.LIMITED);
			writer.SetMaxBufferedDocs(2);
			writer.SetMergeFactor(50);
			writer.SetRAMBufferSizeMB(IndexWriter.DISABLE_AUTO_FLUSH);
			
			Document document = new Document();
			
			document = new Document();
			Field storedField = new Field("stored", "stored", Field.Store.YES, Field.Index.NO);
			document.Add(storedField);
			Field termVectorField = new Field("termVector", "termVector", Field.Store.NO, Field.Index.NOT_ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS);
			document.Add(termVectorField);
			for (int i = 0; i < 98; i++)
				writer.AddDocument(document);
			writer.Close();
			
			IndexReader ir = IndexReader.Open(dir);
			Assert.AreEqual(98, ir.MaxDoc());
			Assert.AreEqual(98, ir.NumDocs());
			for (int i = 0; i < 98; i += 2)
				ir.DeleteDocument(i);
			Assert.AreEqual(49, ir.NumDocs());
			ir.Close();
			
			writer = new IndexWriter(dir, new StandardAnalyzer(), IndexWriter.MaxFieldLength.LIMITED);
			// Force many merges to happen
			writer.SetMergeFactor(3);
			writer.ExpungeDeletes(false);
			writer.Close();
			ir = IndexReader.Open(dir);
			Assert.AreEqual(49, ir.MaxDoc());
			Assert.AreEqual(49, ir.NumDocs());
			ir.Close();
			dir.Close();
		}
开发者ID:Rationalle,项目名称:ravendb,代码行数:38,代码来源:TestIndexWriter.cs


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