You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@lucenenet.apache.org by Frank Yu <fr...@farpoint.com> on 2010/11/09 01:05:09 UTC

Simultaneous Index Update and Search

Hi All,

I am using Lucene.Net 2.9.2 to index and search millions of records. Index
search works fine as long as there is no index update. Once there is an
index update, the CPU usage goes up very high (100%) that impacts the
searching. 

I have three instances of IndexSearcher in the SearcherList. The index
update will close the first one and add a new one. The search will always
use the last one in the list.  Does anyone have any suggestion why the CPU
is so high?

//check the first CDSearcher 
IndexReader oldReader = SearcherList.First.Value.GetIndexReader();
if (!oldReader.IsCurrent())
{
     IndexReader newReader = oldReader.Reopen();
     if (oldReader != newReader)
     {
         // close the first CDSearcher on the list
         SearcherList.First.Value.Close();
         oldReader.Close();
         SearcherList.RemoveFirst();                        
         SearcherList.AddLast(new IndexSearcher(newReader));
      }
}

Thanks,

Frank