1
Vote

Error: Object reference not set to an instance of an object

description

Hello,

In my search part, I tried to open a Lucene.Net.Store.S3.Directory by doing this:

Directory directory = new Directory(accessKey, secretKey, bucketName);
Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_29);
IndexReader indexReader = IndexReader.Open(directory, true);

I got an exception from the last line of code.

"Object reference not set to an instance of an object
at Lucene.Net.Store.SimpleFSDirectory.SimpleFSIndexInput.ReadInternal(Byte[] b, Int32 offset, Int32 len) at Lucene.Net.Store.BufferedIndexInput.Refill()
at Lucene.Net.Store.BufferedIndexInput.ReadBytes(Byte[] b, Int32 offset, Int32 len, Boolean useBuffer)
at Lucene.Net.Store.BufferedIndexInput.ReadBytes(Byte[] b, Int32 offset, Int32 len)
at Lucene.Net.Store.S3.IndexInput.ReadBytes(Byte[] b, Int32 offset, Int32 len) in c:\Visual Studio\OtherSVNs\LuceneNetS3\IndexInput.cs:line 71
at Lucene.Net.Store.IndexInput.ReadBytes(Byte[] b, Int32 offset, Int32 len, Boolean useBuffer)
at Lucene.Net.Index.CompoundFileReader.CSIndexInput.ReadInternal(Byte[] b, Int32 offset, Int32 len)
at Lucene.Net.Store.BufferedIndexInput.Refill()
at Lucene.Net.Store.BufferedIndexInput.ReadByte()
at Lucene.Net.Store.IndexInput.ReadInt()
at Lucene.Net.Index.SegmentTermEnum..ctor(IndexInput i, FieldInfos fis, Boolean isi)
at Lucene.Net.Index.TermInfosReader..ctor(Directory dir, String seg, FieldInfos fis, Int32 readBufferSize, Int32 indexDivisor)
at Lucene.Net.Index.SegmentReader.CoreReaders..ctor(SegmentReader origInstance, Directory dir, SegmentInfo si, Int32 readBufferSize, Int32 termsIndexDivisor)
at Lucene.Net.Index.SegmentReader.Get(Boolean readOnly, Directory dir, SegmentInfo si, Int32 readBufferSize, Boolean doOpenStores, Int32 termInfosIndexDivisor)
at Lucene.Net.Index.SegmentReader.Get(Boolean readOnly, SegmentInfo si, Int32 termInfosIndexDivisor)
at Lucene.Net.Index.DirectoryReader..ctor(Directory directory, SegmentInfos sis, IndexDeletionPolicy deletionPolicy, Boolean readOnly, Int32 termInfosIndexDivisor)
at Lucene.Net.Index.ReadOnlyDirectoryReader..ctor(Directory directory, SegmentInfos sis, IndexDeletionPolicy deletionPolicy, Int32 termInfosIndexDivisor)
at Lucene.Net.Index.DirectoryReader.AnonymousClassFindSegmentsFile.DoBody(String segmentFileName)
at Lucene.Net.Index.SegmentInfos.FindSegmentsFile.Run(IndexCommit commit)
at Lucene.Net.Index.DirectoryReader.Open(Directory directory, IndexDeletionPolicy deletionPolicy, IndexCommit commit, Boolean readOnly, Int32 termInfosIndexDivisor)
at Lucene.Net.Index.IndexReader.Open(Directory directory, IndexDeletionPolicy deletionPolicy, IndexCommit commit, Boolean readOnly, Int32 termInfosIndexDivisor)
at Lucene.Net.Index.IndexReader.Open(Directory directory, Boolean readOnly)
"

Could you please provide some help?

Thanks.

comments

qingdou wrote Aug 14, 2013 at 9:52 PM

Fixed!

Add an override function into 'IndexOutput.cs' which allowed to add 200+ documents into the IndexWriter:
    public override void SetLength(long length)
    {
        indexOutput.SetLength(length);
    }