コード例 #1
0
        public virtual void  Test()
        {
            Assert.IsTrue(dir != null);
            Assert.IsTrue(fieldInfos != null);
            FieldsReader reader = new FieldsReader(dir, TEST_SEGMENT_NAME, fieldInfos);

            Assert.IsTrue(reader != null);
            Assert.IsTrue(reader.Size() == 1);
            Document doc = reader.Doc(0, null);

            Assert.IsTrue(doc != null);
            Assert.IsTrue(doc.GetField(DocHelper.TEXT_FIELD_1_KEY) != null);

            Fieldable field = doc.GetField(DocHelper.TEXT_FIELD_2_KEY);

            Assert.IsTrue(field != null);
            Assert.IsTrue(field.IsTermVectorStored() == true);

            Assert.IsTrue(field.IsStoreOffsetWithTermVector() == true);
            Assert.IsTrue(field.IsStorePositionWithTermVector() == true);
            Assert.IsTrue(field.GetOmitNorms() == false);
            Assert.IsTrue(field.GetOmitTf() == false);

            field = doc.GetField(DocHelper.TEXT_FIELD_3_KEY);
            Assert.IsTrue(field != null);
            Assert.IsTrue(field.IsTermVectorStored() == false);
            Assert.IsTrue(field.IsStoreOffsetWithTermVector() == false);
            Assert.IsTrue(field.IsStorePositionWithTermVector() == false);
            Assert.IsTrue(field.GetOmitNorms() == true);
            Assert.IsTrue(field.GetOmitTf() == false);

            field = doc.GetField(DocHelper.NO_TF_KEY);
            Assert.IsTrue(field != null);
            Assert.IsTrue(field.IsTermVectorStored() == false);
            Assert.IsTrue(field.IsStoreOffsetWithTermVector() == false);
            Assert.IsTrue(field.IsStorePositionWithTermVector() == false);
            Assert.IsTrue(field.GetOmitNorms() == false);
            Assert.IsTrue(field.GetOmitTf() == true);
            reader.Close();
        }