public virtual void TestUpdateSameDocMultipleTimes()
{
Directory dir = NewDirectory();
IndexWriterConfig conf = NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random()));
IndexWriter writer = new IndexWriter(dir, conf);
Document doc = new Document();
doc.Add(new StringField("key", "doc", Store.NO));
doc.Add(new BinaryDocValuesField("bdv", ToBytes(5L)));
writer.AddDocument(doc); // flushed document
writer.Commit();
writer.AddDocument(doc); // in-memory document
writer.UpdateBinaryDocValue(new Term("key", "doc"), "bdv", ToBytes(17L)); // update existing field
writer.UpdateBinaryDocValue(new Term("key", "doc"), "bdv", ToBytes(3L)); // update existing field 2nd time in this commit
writer.Dispose();
DirectoryReader reader = DirectoryReader.Open(dir);
AtomicReader r = SlowCompositeReaderWrapper.Wrap(reader);
BinaryDocValues bdv = r.GetBinaryDocValues("bdv");
BytesRef scratch = new BytesRef();
for (int i = 0; i < r.MaxDoc; i++)
{
Assert.AreEqual(3, GetValue(bdv, i, scratch));
}
reader.Dispose();
dir.Dispose();
}