Lucene.Net.Index.TestNumericDocValuesUpdates.TestMultipleNumericDocValues C# (CSharp) Method

TestMultipleNumericDocValues() private method

private TestMultipleNumericDocValues ( ) : void
return void
        public virtual void TestMultipleNumericDocValues()
        {
            Directory dir = NewDirectory();
            IndexWriterConfig conf = NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random()));
            conf.SetMaxBufferedDocs(10); // prevent merges
            IndexWriter writer = new IndexWriter(dir, conf);

            for (int i = 0; i < 2; i++)
            {
                Document doc = new Document();
                doc.Add(new StringField("dvUpdateKey", "dv", Store.NO));
                doc.Add(new NumericDocValuesField("ndv1", i));
                doc.Add(new NumericDocValuesField("ndv2", i));
                writer.AddDocument(doc);
            }
            writer.Commit();

            // update all docs' ndv1 field
            writer.UpdateNumericDocValue(new Term("dvUpdateKey", "dv"), "ndv1", 17L);
            writer.Dispose();

            DirectoryReader reader = DirectoryReader.Open(dir);
            AtomicReader r = (AtomicReader)reader.Leaves[0].Reader;
            NumericDocValues ndv1 = r.GetNumericDocValues("ndv1");
            NumericDocValues ndv2 = r.GetNumericDocValues("ndv2");
            for (int i = 0; i < r.MaxDoc; i++)
            {
                Assert.AreEqual(17, ndv1.Get(i));
                Assert.AreEqual(i, ndv2.Get(i));
            }

            reader.Dispose();
            dir.Dispose();
        }