lucenenet-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kevin Miller" <>
Subject RealTime Search Null Reference Exception.
Date Mon, 16 Aug 2010 19:16:07 GMT
I did some searches for this issue and didn't find anything. Apologies
if this is known. 

I am calling IndexWriter.GetReader() from an IndexWriter instance which
is getting used in a multithreaded scenario. I want to do real-time
searches against potentially uncommitted documents. My indexing
infrastructure keeps only one IndexWriter open at a time (of course).

Works great except that very rarely the request to GetReader() will
throw a NullReferenceException. Here is the stack trace: 

System.NullReferenceException: Object reference not set to an instance
of an object.
   at Lucene.Net.Index.SegmentReader.Norm.Clone()
   at Lucene.Net.Index.SegmentReader.ReopenSegment(SegmentInfo si,
Boolean doClone, Boolean openReadOnly)
   at Lucene.Net.Index.SegmentReader.Clone(Boolean openReadOnly)
info, Boolean doOpenStores, Int32 termInfosIndexDivisor)
   at Lucene.Net.Index.DirectoryReader..ctor(IndexWriter writer,
SegmentInfos infos, Int32 termInfosIndexDivisor)
   at Lucene.Net.Index.IndexWriter.GetReader(Int32
   at Lucene.Net.Index.IndexWriter.GetReader()
   at Dovetail.Search.Indexing.IndexWriterWrapper.withSearcher[T](Func`2
   at ...

For context. My withSearcher<T> code: 

public T withSearcher<T>(Func<IndexSearcher, T> func)
	var indexReader = _indexWriter.GetReader();
	var searcher = new IndexSearcher(indexReader);

		return func(searcher);

If it helps I am using a FSDirectory. Any suggestions? Or ideas how I
might better characterize this? 

I can work around by switching back to searching on committed documents
via a search created from a read-only IndexReader from a Directory. I
wanted to do real time searches to avoid explicit commits (which are not
always necessary) in my indexing workflow.  

Kevin @ Dovetail Software

-----Original Message-----

View raw message