Tutorial :PHP: Checking if a directory contains a Zend_Search_Lucene index


I am looking for a reliable way to check to see if a directory contains a Zend_Search_Lucene index. Currently, the only way I have managed to work this out is to check the contents of an exception returned to me using the following code:

<?php  try  {      $newIndex = Zend_Search_Lucene::open( $luceneDir );  } catch ( Zend_Search_Lucene_Exception $e ) {      if ( strpos( $e->getMessage( ), 'in the specified directory' ) !== false )      {          $newIndex = Zend_Search_Lucene::create( $luceneDir );      }  }  ?>  

This method is not ideal, and a check of the API did not seem very useful. Does anyone know if there is a simple way to see if $luceneDir contains a Zend_Search_Lucene index?


You might first try to check if there is index segments number file


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »