コード例 #1
0
        public void TestSegmentWarmer()
        {
            Directory   dir = new MockRAMDirectory();
            IndexWriter w   = new IndexWriter(dir, new WhitespaceAnalyzer(), IndexWriter.MaxFieldLength.UNLIMITED);

            w.SetMaxBufferedDocs(2);
            w.GetReader().Close();
            w.SetMergedSegmentWarmer(new AnonymousIndexReaderWarmer());

            Document doc = new Document();

            doc.Add(new Field("foo", "bar", Field.Store.YES, Field.Index.NOT_ANALYZED));
            for (int i = 0; i < 20; i++)
            {
                w.AddDocument(doc);
            }
            w.WaitForMerges();
            w.Close();
            dir.Close();
        }
コード例 #2
0
        public virtual void  TestMergeWarmer()
        {
            Directory   dir1   = new MockRAMDirectory();
            IndexWriter writer = new IndexWriter(dir1, new WhitespaceAnalyzer(), IndexWriter.MaxFieldLength.LIMITED);

            writer.SetInfoStream(infoStream);

            // create the index
            CreateIndexNoClose(false, "test", writer);

            // get a reader to put writer into near real-time mode
            IndexReader r1 = writer.GetReader();

            // Enroll warmer
            MyWarmer warmer = new MyWarmer();

            writer.SetMergedSegmentWarmer(warmer);
            writer.SetMergeFactor(2);
            writer.SetMaxBufferedDocs(2);

            for (int i = 0; i < 10; i++)
            {
                writer.AddDocument(CreateDocument(i, "test", 4));
            }
            ((ConcurrentMergeScheduler)writer.GetMergeScheduler()).Sync();

            Assert.IsTrue(warmer.warmCount > 0);
            int count = warmer.warmCount;

            writer.AddDocument(CreateDocument(17, "test", 4));
            writer.Optimize();
            Assert.IsTrue(warmer.warmCount > count);

            writer.Close();
            r1.Close();
            dir1.Close();
        }
コード例 #3
0
		public virtual void  TestMergeWarmer()
		{
			
			Directory dir1 = new MockRAMDirectory();
			IndexWriter writer = new IndexWriter(dir1, new WhitespaceAnalyzer(), IndexWriter.MaxFieldLength.LIMITED);
			writer.SetInfoStream(infoStream);
			
			// create the index
			CreateIndexNoClose(false, "test", writer);
			
			// get a reader to put writer into near real-time mode
			IndexReader r1 = writer.GetReader();
			
			// Enroll warmer
			MyWarmer warmer = new MyWarmer();
			writer.SetMergedSegmentWarmer(warmer);
			writer.SetMergeFactor(2);
			writer.SetMaxBufferedDocs(2);
			
			for (int i = 0; i < 10; i++)
			{
				writer.AddDocument(CreateDocument(i, "test", 4));
			}
			((ConcurrentMergeScheduler) writer.GetMergeScheduler()).Sync();
			
			Assert.IsTrue(warmer.warmCount > 0);
			int count = warmer.warmCount;
			
			writer.AddDocument(CreateDocument(17, "test", 4));
			writer.Optimize();
			Assert.IsTrue(warmer.warmCount > count);
			
			writer.Close();
			r1.Close();
			dir1.Close();
		}
コード例 #4
0
        public void TestSegmentWarmer()
        {
            Directory dir = new MockRAMDirectory();
            IndexWriter w = new IndexWriter(dir, new WhitespaceAnalyzer(), IndexWriter.MaxFieldLength.UNLIMITED);
            w.SetMaxBufferedDocs(2);
            w.GetReader().Close();
            w.SetMergedSegmentWarmer(new AnonymousIndexReaderWarmer());

            Document doc = new Document();
            doc.Add(new Field("foo", "bar", Field.Store.YES, Field.Index.NOT_ANALYZED));
            for (int i = 0; i < 20; i++)
            {
                w.AddDocument(doc);
            }
            w.WaitForMerges();
            w.Close();
            dir.Close();
        }