Home - Web Developer Blog

Zend Framework

“Index is under processing now” Error in Zend Lucene Index

If you use the Zend Lucene Index feature within the Zend Framework then you may have come accross the “Index is under processing now” error message. This this exception will be thrown when an attempt to open or add to a corrupt index is made.

Solution

1. Call optimize(); on the index object periodically. This could be included as part of a cron job that is executed daily for example to prevent potential issues occuring.

2. Handle the exception – if you try to access the index and it has managed to become corrupt, then handle the exception by rebuilding it from scratch. The following example code attempts to open the index; if it is corrupt, it deletes all files within the index directory and then creates it from scratch again. It also logs the error to application/logs (make sure this directory is writeable). Depending on the size of the index, you could re-add all of the records as part of this code, although often that is not pratical due to the amount of records.

try
{
	$index = Zend_Search_Lucene::open($dir);
}
catch(Zend_Search_Lucene_Exception $e)
{
	if($e->getMessage() == 'Index is under processing now')
	{
		//index is corrupt - no choice but to delete it and create it from scratch
		foreach(glob($dir.'/*') as $v)
		{
			unlink($v);
		}
 
		$writer = new Zend_Log_Writer_Stream(APPLICATION_PATH . '/log/index.xml');
		$writer->setFormatter(new Zend_Log_Formatter_Xml());
		$log = new Zend_Log($writer);
		$log->setEventItem('timestamp', date('D, j M Y H:i:s', time()));
		$log->debug($e->getMessage() . "::" . get_class($this) . "n" . $e->getTraceAsString());
 
		$index = Zend_Search_Lucene::create($dir);
	}
	else
	{
		throw $e;
	}
}

  • Nitin Kumar

    Hi,

    I got same error but another exception came Zend_log_Exception with this message…

    ‘”APPLICATION_PATH/log/index.xml” cannot be opened with mode “a”‘.
    I remind that i got this exception when i was re indexing products by SSH.
    ____________________________________________________________

    So what i did when re indexing is done in var/indexer  two folders are created 0 and 1 .Several files are kept there CSV`s etc.

    So for solving this problem i renamed those folders(0 and 1) then my problem solved.

    Author should improve this article…

    Thanks,

     

Net Tuts Code Canyon Get Noticed - $7.99 .Com or .CO from GoDaddy.com!