Lucene.Net.Index.TestDocValuesIndexing.TestMixedTypesViaAddIndexes C# (CSharp) Method

TestMixedTypesViaAddIndexes() private method

private TestMixedTypesViaAddIndexes ( ) : void
return void
        public virtual void TestMixedTypesViaAddIndexes()
        {
            Directory dir = NewDirectory();
            IndexWriter w = new IndexWriter(dir, NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random())));
            Document doc = new Document();
            doc.Add(new NumericDocValuesField("foo", 0));
            w.AddDocument(doc);

            // Make 2nd index w/ inconsistent field
            Directory dir2 = NewDirectory();
            IndexWriter w2 = new IndexWriter(dir2, NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random())));
            doc = new Document();
            doc.Add(new SortedDocValuesField("foo", new BytesRef("hello")));
            w2.AddDocument(doc);
            w2.Dispose();

            try
            {
                w.AddIndexes(dir2);
            }
            catch (System.ArgumentException iae)
            {
                // expected
            }

            IndexReader r = DirectoryReader.Open(dir2);
            try
            {
                w.AddIndexes(new IndexReader[] { r });
            }
            catch (System.ArgumentException iae)
            {
                // expected
            }

            r.Dispose();
            dir2.Dispose();
            w.Dispose();
            dir.Dispose();
        }