本文整理汇总了C#中Lucene.Net.Index.RandomIndexWriter.DeleteAll方法的典型用法代码示例。如果您正苦于以下问题:C# Lucene.Net.Index.RandomIndexWriter.DeleteAll方法的具体用法?C# Lucene.Net.Index.RandomIndexWriter.DeleteAll怎么用?C# Lucene.Net.Index.RandomIndexWriter.DeleteAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lucene.Net.Index.RandomIndexWriter
的用法示例。
在下文中一共展示了Lucene.Net.Index.RandomIndexWriter.DeleteAll方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Build
private static IndexReader Build(Random random, TestIndex index)
{
/* build an index */
Document doc = new Document();
Field idField = NewStringField(random, "id", "", Field.Store.YES);
Field randField = NewStringField(random, "rand", "", Field.Store.YES);
Field bodyField = NewStringField(random, "body", "", Field.Store.NO);
doc.Add(idField);
doc.Add(randField);
doc.Add(bodyField);
RandomIndexWriter writer = new RandomIndexWriter(random, index.Index, NewIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer(random)).SetOpenMode(OpenMode.CREATE).SetMaxBufferedDocs(TestUtil.NextInt(random, 50, 1000)).SetMergePolicy(NewLogMergePolicy()));
TestUtil.ReduceOpenFiles(writer.w);
while (true)
{
int minCount = 0;
int maxCount = 0;
for (int d = MinId; d <= MaxId; d++)
{
idField.StringValue = Pad(d);
int r = index.AllowNegativeRandomInts ? random.Next() : random.Next(int.MaxValue);
if (index.MaxR < r)
{
index.MaxR = r;
maxCount = 1;
}
else if (index.MaxR == r)
{
maxCount++;
}
if (r < index.MinR)
{
index.MinR = r;
minCount = 1;
}
else if (r == index.MinR)
{
minCount++;
}
randField.StringValue = Pad(r);
bodyField.StringValue = "body";
writer.AddDocument(doc);
}
if (minCount == 1 && maxCount == 1)
{
// our subclasses rely on only 1 doc having the min or
// max, so, we loop until we satisfy that. it should be
// exceedingly rare (Yonik calculates 1 in ~429,000)
// times) that this loop requires more than one try:
IndexReader ir = writer.Reader;
writer.Dispose();
return ir;
}
// try again
writer.DeleteAll();
}
}