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


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

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


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

示例1: MakeIndex

            internal virtual void MakeIndex()
            {
                // we use RAMDirectory here, because we dont want to stay on open files on Windows:
                  d = new RAMDirectory();
                  RandomIndexWriter w = new RandomIndexWriter(Random(), d);
                  Document doc = new Document();
                  doc.Add(newField("ints", "1", StringField.TYPE_NOT_STORED));
                  w.AddDocument(doc);
                  w.ForceMerge(1);
                  r = w.Reader;
                  w.Dispose();

                  SubR = (AtomicReader)(r.Leaves()[0]).Reader();
            }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:14,代码来源:TestFailOnFieldCacheInsanity.cs

示例2: TestLongFieldCache

 public virtual void TestLongFieldCache()
 {
     Directory dir = NewDirectory();
     IndexWriterConfig cfg = NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random()));
     cfg.SetMergePolicy(NewLogMergePolicy());
     RandomIndexWriter iw = new RandomIndexWriter(Random(), dir, cfg);
     Document doc = new Document();
     LongField field = new LongField("f", 0L, Field.Store.YES);
     doc.Add(field);
     long[] values = new long[TestUtil.NextInt(Random(), 1, 10)];
     for (int i = 0; i < values.Length; ++i)
     {
         long v;
         switch (Random().Next(10))
         {
             case 0:
                 v = long.MinValue;
                 break;
             case 1:
                 v = 0;
                 break;
             case 2:
                 v = long.MaxValue;
                 break;
             default:
                 v = TestUtil.NextLong(Random(), -10, 10);
                 break;
         }
         values[i] = v;
         if (v == 0 && Random().NextBoolean())
         {
             // missing
             iw.AddDocument(new Document());
         }
         else
         {
             field.LongValue = v;
             iw.AddDocument(doc);
         }
     }
     iw.ForceMerge(1);
     DirectoryReader reader = iw.Reader;
     Longs longs = FieldCache_Fields.DEFAULT.GetLongs(GetOnlySegmentReader(reader), "f", false);
     for (int i = 0; i < values.Length; ++i)
     {
         Assert.AreEqual(values[i], longs.Get(i));
     }
     reader.Dispose();
     iw.Dispose();
     dir.Dispose();
 }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:51,代码来源:TestFieldCache.cs

示例3: TestBooleanScorerMax

        public virtual void TestBooleanScorerMax()
        {
            Directory dir = NewDirectory();
            RandomIndexWriter riw = new RandomIndexWriter(Random(), dir, NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random())));

            int docCount = AtLeast(10000);

            for (int i = 0; i < docCount; i++)
            {
                Document doc = new Document();
                doc.Add(NewField("field", "a", TextField.TYPE_NOT_STORED));
                riw.AddDocument(doc);
            }

            riw.ForceMerge(1);
            IndexReader r = riw.Reader;
            riw.Dispose();

            IndexSearcher s = NewSearcher(r);
            BooleanQuery bq = new BooleanQuery();
            bq.Add(new TermQuery(new Term("field", "a")), BooleanClause.Occur.SHOULD);
            bq.Add(new TermQuery(new Term("field", "a")), BooleanClause.Occur.SHOULD);

            Weight w = s.CreateNormalizedWeight(bq);

            Assert.AreEqual(1, s.IndexReader.Leaves.Count);
            BulkScorer scorer = w.BulkScorer(s.IndexReader.Leaves[0], false, null);

            FixedBitSet hits = new FixedBitSet(docCount);
            AtomicInteger end = new AtomicInteger();
            Collector c = new CollectorAnonymousInnerClassHelper(this, scorer, hits, end);

            while (end.Get() < docCount)
            {
                int inc = TestUtil.NextInt(Random(), 1, 1000);
                end.AddAndGet(inc);
                scorer.Score(c, end.Get());
            }

            Assert.AreEqual(docCount, hits.Cardinality());
            r.Dispose();
            dir.Dispose();
        }
开发者ID:ChristopherHaws,项目名称:lucenenet,代码行数:43,代码来源:TestBooleanOr.cs

示例4: TestCustomDoublesValueSource

        public virtual void TestCustomDoublesValueSource()
        {
            Directory dir = NewDirectory();
            RandomIndexWriter writer = new RandomIndexWriter(Random(), dir);

            Document doc = new Document();
            writer.AddDocument(doc);
            writer.AddDocument(doc);
            writer.AddDocument(doc);

            // Test wants 3 docs in one segment:
            writer.ForceMerge(1);

            var vs = new ValueSourceAnonymousInnerClassHelper(this, doc);

            FacetsConfig config = new FacetsConfig();

            FacetsCollector fc = new FacetsCollector();

            IndexReader r = writer.Reader;
            IndexSearcher s = NewSearcher(r);
            s.Search(new MatchAllDocsQuery(), fc);

            DoubleRange[] ranges = new DoubleRange[] { new DoubleRange("< 1", 0.0, true, 1.0, false), new DoubleRange("< 2", 0.0, true, 2.0, false), new DoubleRange("< 5", 0.0, true, 5.0, false), new DoubleRange("< 10", 0.0, true, 10.0, false), new DoubleRange("< 20", 0.0, true, 20.0, false), new DoubleRange("< 50", 0.0, true, 50.0, false) };

            Filter fastMatchFilter;
            AtomicBoolean filterWasUsed = new AtomicBoolean();
            if (Random().NextBoolean())
            {
                // Sort of silly:
                fastMatchFilter = new CachingWrapperFilterAnonymousInnerClassHelper(this, new QueryWrapperFilter(new MatchAllDocsQuery()), filterWasUsed);
            }
            else
            {
                fastMatchFilter = null;
            }

            if (VERBOSE)
            {
                Console.WriteLine("TEST: fastMatchFilter=" + fastMatchFilter);
            }

            Facets facets = new DoubleRangeFacetCounts("field", vs, fc, fastMatchFilter, ranges);

            Assert.AreEqual("dim=field path=[] value=3 childCount=6\n  < 1 (0)\n  < 2 (1)\n  < 5 (3)\n  < 10 (3)\n  < 20 (3)\n  < 50 (3)\n", facets.GetTopChildren(10, "field").ToString());
            Assert.True(fastMatchFilter == null || filterWasUsed.Get());

            DrillDownQuery ddq = new DrillDownQuery(config);
            ddq.Add("field", ranges[1].GetFilter(fastMatchFilter, vs));

            // Test simple drill-down:
            Assert.AreEqual(1, s.Search(ddq, 10).TotalHits);

            // Test drill-sideways after drill-down
            DrillSideways ds = new DrillSidewaysAnonymousInnerClassHelper2(this, s, config, (TaxonomyReader)null, vs, ranges, fastMatchFilter);

            DrillSidewaysResult dsr = ds.Search(ddq, 10);
            Assert.AreEqual(1, dsr.Hits.TotalHits);
            Assert.AreEqual("dim=field path=[] value=3 childCount=6\n  < 1 (0)\n  < 2 (1)\n  < 5 (3)\n  < 10 (3)\n  < 20 (3)\n  < 50 (3)\n", dsr.Facets.GetTopChildren(10, "field").ToString());

            IOUtils.Close(r, writer, dir);
        }
开发者ID:WakeflyCBass,项目名称:lucenenet,代码行数:62,代码来源:TestRangeFacetCounts.cs

示例5: SetUp

        public override void SetUp()
        {
            base.SetUp();
            Directory = NewDirectory();
            RandomIndexWriter writer = new RandomIndexWriter(Random(), Directory, NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random())).SetMergePolicy(NewLogMergePolicy()));

            Document doc = new Document();
            doc.Add(NewTextField("field", "one two three four five", Field.Store.YES));
            doc.Add(NewTextField("sorter", "b", Field.Store.YES));
            writer.AddDocument(doc);

            doc = new Document();
            doc.Add(NewTextField("field", "one two three four", Field.Store.YES));
            doc.Add(NewTextField("sorter", "d", Field.Store.YES));
            writer.AddDocument(doc);

            doc = new Document();
            doc.Add(NewTextField("field", "one two three y", Field.Store.YES));
            doc.Add(NewTextField("sorter", "a", Field.Store.YES));
            writer.AddDocument(doc);

            doc = new Document();
            doc.Add(NewTextField("field", "one two x", Field.Store.YES));
            doc.Add(NewTextField("sorter", "c", Field.Store.YES));
            writer.AddDocument(doc);

            // tests here require single segment (eg try seed
            // 8239472272678419952L), because SingleDocTestFilter(x)
            // blindly accepts that docID in any sub-segment
            writer.ForceMerge(1);

            Reader = writer.Reader;
            writer.Dispose();

            Searcher = NewSearcher(Reader);

            Query = new TermQuery(new Term("field", "three"));
            Filter = NewStaticFilterB();
        }
开发者ID:WakeflyCBass,项目名称:lucenenet,代码行数:39,代码来源:TestFilteredQuery.cs

示例6: Populate

 private static void Populate(Directory directory, IndexWriterConfig config)
 {
     RandomIndexWriter writer = new RandomIndexWriter(Random(), directory, config);
     for (int i = 0; i < NUMBER_OF_DOCUMENTS; i++)
     {
         Document document = new Document();
         for (int f = 0; f < NUMBER_OF_FIELDS; f++)
         {
             document.Add(NewStringField("field" + f, Text, Field.Store.NO));
         }
         writer.AddDocument(document);
     }
     writer.ForceMerge(1);
     writer.Dispose();
 }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:15,代码来源:TestTermInfosReaderIndex.cs

示例7: BeforeClass

        public static void BeforeClass()
        {
            Dir = NewDirectory();
            Sdir1 = NewDirectory();
            Sdir2 = NewDirectory();
            RandomIndexWriter writer = new RandomIndexWriter(Random(), Dir, new MockAnalyzer(Random()));
            RandomIndexWriter swriter1 = new RandomIndexWriter(Random(), Sdir1, new MockAnalyzer(Random()));
            RandomIndexWriter swriter2 = new RandomIndexWriter(Random(), Sdir2, new MockAnalyzer(Random()));

            for (int i = 0; i < 10; i++)
            {
                Document doc = new Document();
                doc.Add(NewStringField("data", Convert.ToString(i), Field.Store.NO));
                writer.AddDocument(doc);
                ((i % 2 == 0) ? swriter1 : swriter2).AddDocument(doc);
            }
            writer.ForceMerge(1);
            swriter1.ForceMerge(1);
            swriter2.ForceMerge(1);
            writer.Dispose();
            swriter1.Dispose();
            swriter2.Dispose();

            Reader = DirectoryReader.Open(Dir);
            Searcher = NewSearcher(Reader);

            MultiReader = new MultiReader(new IndexReader[] { DirectoryReader.Open(Sdir1), DirectoryReader.Open(Sdir2) }, true);
            MultiSearcher = NewSearcher(MultiReader);

            MultiReaderDupls = new MultiReader(new IndexReader[] { DirectoryReader.Open(Sdir1), DirectoryReader.Open(Dir) }, true);
            MultiSearcherDupls = NewSearcher(MultiReaderDupls);
        }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:32,代码来源:TestMultiTermQueryRewrites.cs


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