示例#1
0
        public void ReadSegmentsGenTest()
        {
            // check the generation in the directory
            IndexReader reader = IndexReader.Open(this.directory, true);
            IndexCommit commit = reader.GetIndexCommit();

            // create a SegmentsGenCommit
            SegmentsGenCommit sgCommit = new SegmentsGenCommit(this.directory);

            Assert.AreEqual(commit.GetGeneration(), sgCommit.GetGeneration());
            Assert.AreEqual(commit.GetSegmentsFileName(), sgCommit.GetSegmentsFileName());
        }
示例#2
0
        public void OpenWriterWithCommit()
        {
            SegmentsGenCommit sgCommit = new SegmentsGenCommit(this.directory);
            IndexWriter       writer   = new IndexWriter(this.directory, new WhitespaceAnalyzer(), null, IndexWriter.MaxFieldLength.UNLIMITED, sgCommit);

            Assert.AreEqual(10, writer.MaxDoc());
            IndexReader reader = writer.GetReader();

            IndexCommit commit = reader.GetIndexCommit();

            Assert.AreEqual(commit.GetGeneration(), sgCommit.GetGeneration());
            Assert.AreEqual(commit.GetSegmentsFileName(), sgCommit.GetSegmentsFileName());
        }