Lucene.Net.Index.IndexReader.Document C# (CSharp) Method

Document() public abstract method

Get the Lucene.Net.Documents.Document at the n th position. The FieldSelector may be used to determine what Lucene.Net.Documents.Fields to load and how they should be loaded. NOTE: If this Reader (more specifically, the underlying FieldsReader) is closed before the lazy Lucene.Net.Documents.Field is loaded an exception may be thrown. If you want the value of a lazy Lucene.Net.Documents.Field to be available after closing you must explicitly load it or fetch the Document again with a new loader.

NOTE: for performance reasons, this method does not check if the requested document is deleted, and therefore asking for a deleted document may yield unspecified results. Usually this is not required, however you can call IsDeleted(int) with the requested document ID to verify the document is not deleted.

public abstract Document ( int n, Lucene.Net.Documents.FieldSelector fieldSelector ) : Lucene.Net.Documents.Document
n int Get the document at the nth position ///
fieldSelector Lucene.Net.Documents.FieldSelector The to use to determine what /// Fields should be loaded on the Document. May be null, in which case /// all Fields will be loaded. ///
return Lucene.Net.Documents.Document
		public abstract Document Document(int n, FieldSelector fieldSelector);
		

Same methods

IndexReader::Document ( int n ) : Lucene.Net.Documents.Document

Usage Example

Example #1
0
        public virtual void  TestCompressionTools()
        {
            IFieldable binaryFldCompressed = new Field("binaryCompressed", CompressionTools.Compress(System.Text.UTF8Encoding.UTF8.GetBytes(binaryValCompressed)), Field.Store.YES);
            IFieldable stringFldCompressed = new Field("stringCompressed", CompressionTools.CompressString(binaryValCompressed), Field.Store.YES);

            Document doc = new Document();

            doc.Add(binaryFldCompressed);
            doc.Add(stringFldCompressed);

            /* add the doc to a ram index */
            MockRAMDirectory dir    = new MockRAMDirectory();
            IndexWriter      writer = new IndexWriter(dir, new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED, null);

            writer.AddDocument(doc, null);
            writer.Close();

            /* open a reader and fetch the document */
            IndexReader reader        = IndexReader.Open((Directory)dir, false, null);
            Document    docFromReader = reader.Document(0, null);

            Assert.IsTrue(docFromReader != null);

            /* fetch the binary compressed field and compare it's content with the original one */
            System.String binaryFldCompressedTest = new System.String(System.Text.UTF8Encoding.UTF8.GetChars(CompressionTools.Decompress(docFromReader.GetBinaryValue("binaryCompressed", null))));
            Assert.IsTrue(binaryFldCompressedTest.Equals(binaryValCompressed));
            Assert.IsTrue(CompressionTools.DecompressString(docFromReader.GetBinaryValue("stringCompressed", null)).Equals(binaryValCompressed));

            reader.Close();
            dir.Close();
        }
All Usage Examples Of Lucene.Net.Index.IndexReader::Document