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


C# IndexWriter.SetReaderTermsIndexDivisor方法代码示例

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


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

示例1: TestDeleteFromIndexWriter

		public virtual void  TestDeleteFromIndexWriter()
		{
			bool optimize = true;
			
			Directory dir1 = new MockRAMDirectory();
			IndexWriter writer = new IndexWriter(dir1, new WhitespaceAnalyzer(), IndexWriter.MaxFieldLength.LIMITED);
            writer.SetReaderTermsIndexDivisor(2);
			writer.SetInfoStream(infoStream);
			// create the index
			CreateIndexNoClose(!optimize, "index1", writer);
			writer.Flush(false, true, true);
			// get a reader
			IndexReader r1 = writer.GetReader();
			
			System.String id10 = r1.Document(10).GetField("id").StringValue();
			
			// deleted IW docs should not show up in the next getReader
			writer.DeleteDocuments(new Term("id", id10));
			IndexReader r2 = writer.GetReader();
			Assert.AreEqual(1, Count(new Term("id", id10), r1));
			Assert.AreEqual(0, Count(new Term("id", id10), r2));
			
			System.String id50 = r1.Document(50).GetField("id").StringValue();
			Assert.AreEqual(1, Count(new Term("id", id50), r1));
			
			writer.DeleteDocuments(new Term("id", id50));
			
			IndexReader r3 = writer.GetReader();
			Assert.AreEqual(0, Count(new Term("id", id10), r3));
			Assert.AreEqual(0, Count(new Term("id", id50), r3));
			
			System.String id75 = r1.Document(75).GetField("id").StringValue();
			writer.DeleteDocuments(new TermQuery(new Term("id", id75)));
			IndexReader r4 = writer.GetReader();
			Assert.AreEqual(1, Count(new Term("id", id75), r3));
			Assert.AreEqual(0, Count(new Term("id", id75), r4));
			
			r1.Close();
			r2.Close();
			r3.Close();
			r4.Close();
			writer.Close();
			
			// reopen the writer to verify the delete made it to the directory
			writer = new IndexWriter(dir1, new WhitespaceAnalyzer(), IndexWriter.MaxFieldLength.LIMITED);
			writer.SetInfoStream(infoStream);
			IndexReader w2r1 = writer.GetReader();
			Assert.AreEqual(0, Count(new Term("id", id10), w2r1));
			w2r1.Close();
			writer.Close();
			dir1.Close();
		}
开发者ID:Mpdreamz,项目名称:lucene.net,代码行数:52,代码来源:TestIndexWriterReader.cs


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