public virtual void TestDifferentTypedDocValuesField()
{
Directory d = NewDirectory();
RandomIndexWriter w = new RandomIndexWriter(Random(), d, Similarity, TimeZone);
Document doc = new Document();
// Index doc values are single-valued so we should not
// be able to add same field more than once:
Field f;
doc.Add(f = new NumericDocValuesField("field", 17));
doc.Add(new BinaryDocValuesField("field", new BytesRef("blah")));
try
{
w.AddDocument(doc);
Assert.Fail("didn't hit expected exception");
}
catch (System.ArgumentException iae)
{
// expected
}
doc = new Document();
doc.Add(f);
w.AddDocument(doc);
w.ForceMerge(1);
DirectoryReader r = w.Reader;
w.Dispose();
Assert.AreEqual(17, FieldCache.DEFAULT.GetInts(GetOnlySegmentReader(r), "field", false).Get(0));
r.Dispose();
d.Dispose();
}