public virtual void TestTermDocs(int indexDivisor) { //After adding the document, we should be able to read it back in SegmentReader reader = SegmentReader.Get(info); reader.SetTermInfosIndexDivisor(indexDivisor); Assert.IsTrue(reader != null); SegmentTermDocs segTermDocs = new SegmentTermDocs(reader); Assert.IsTrue(segTermDocs != null); segTermDocs.Seek(new Term(DocHelper.TEXT_FIELD_2_KEY, "field")); if (segTermDocs.Next() == true) { int docId = segTermDocs.Doc(); Assert.IsTrue(docId == 0); int freq = segTermDocs.Freq(); Assert.IsTrue(freq == 3); } reader.Close(); }
public virtual void TestTermDocs(int indexDivisor) { //After adding the document, we should be able to read it back in SegmentReader reader = SegmentReader.Get(true, info, indexDivisor); Assert.IsTrue(reader != null); Assert.AreEqual(indexDivisor, reader.GetTermInfosIndexDivisor()); SegmentTermDocs segTermDocs = new SegmentTermDocs(reader); Assert.IsTrue(segTermDocs != null); segTermDocs.Seek(new Term(DocHelper.TEXT_FIELD_2_KEY, "field")); if (segTermDocs.Next() == true) { int docId = segTermDocs.Doc(); Assert.IsTrue(docId == 0); int freq = segTermDocs.Freq(); Assert.IsTrue(freq == 3); } reader.Close(); }
public virtual void TestTermDocs() { try { //After adding the document, we should be able to read it back in SegmentReader reader = new SegmentReader(new SegmentInfo("test", 1, dir)); Assert.IsTrue(reader != null); SegmentTermDocs segTermDocs = new SegmentTermDocs(reader); Assert.IsTrue(segTermDocs != null); segTermDocs.Seek(new Term(DocHelper.TEXT_FIELD_2_KEY, "Field")); if (segTermDocs.Next() == true) { int docId = segTermDocs.Doc(); Assert.IsTrue(docId == 0); int freq = segTermDocs.Freq(); Assert.IsTrue(freq == 3); } reader.Close(); } catch (System.IO.IOException e) { Assert.IsTrue(false); } }