public virtual void TestCommitUserData()
{
Directory dir = NewDirectory();
IndexWriter w = new IndexWriter(dir, (IndexWriterConfig)NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random())).SetMaxBufferedDocs(2));
for (int j = 0; j < 17; j++)
{
TestIndexWriter.AddDoc(w);
}
w.Dispose();
DirectoryReader r = DirectoryReader.Open(dir);
// commit(Map) never called for this index
Assert.AreEqual(0, r.IndexCommit.UserData.Count);
r.Dispose();
w = new IndexWriter(dir, (IndexWriterConfig)NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random())).SetMaxBufferedDocs(2));
for (int j = 0; j < 17; j++)
{
TestIndexWriter.AddDoc(w);
}
IDictionary<string, string> data = new Dictionary<string, string>();
data["label"] = "test1";
w.CommitData = data;
w.Dispose();
r = DirectoryReader.Open(dir);
Assert.AreEqual("test1", r.IndexCommit.UserData["label"]);
r.Dispose();
w = new IndexWriter(dir, NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random())));
w.ForceMerge(1);
w.Dispose();
dir.Dispose();
}
}