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


C# Lucene.Net.Index.RandomIndexWriter.DeleteAll方法代码示例

本文整理汇总了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();
            }
        }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:63,代码来源:BaseTestRangeFilter.cs


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