I’m having probs with Lucene (just grabbed the latest ZF), I’ve traced it a little, and it seems to be a file locking problem. $index->addDocument($doc); in the script below (more or less copy pasted from the docs) throws an exception from a destructor (ie useless). I removed an @ and vardumped the file names in the code that was causing it (constructor in Zend_Search_Lucene_Storage_File_Filesystem) to get the o/p below.
Anyone experienced this? Got any ideas on how to solve (even tmp patches?)?
require 'Zend/Search/Lucene.php';
$index = Zend_Search_Lucene::create('my-index');
$doc = new Zend_Search_Lucene_Document();
// Store document URL to identify it in the search results
$doc->addField(Zend_Search_Lucene_Field::Text('url', 'xxx'));
// Index document contents
$doc->addField(Zend_Search_Lucene_Field::UnStored('contents', 'some blah bla bl b'));
// Add document to the index
$index->addDocument($doc);
string(27) "my-index/read.lock.file
" string(25) "my-index/segments.gen
" string(28) "my-index/write.lock.file
" string(23) "my-index/segments_4
" string(25) "my-index/segments.gen
" string(23) "my-index/segments_5
" string(28) "my-index/write.lock.file
" string(25) "my-index/segments.gen
" string(23) "my-index/segments_5
" string(19) "my-index/_4.fdx
" string(19) "my-index/_4.fdt
" string(35) "my-index/optimization.lock.file
" string(19) "my-index/_4.fnm
"
Warning: fopen(my-index/_4.fnm) [function.fopen]: failed to open stream: No such file or directory in C:\\wamp\\www\ est\\Zend\\library\\Zend\\Search\\Lucene\\Storage\\File\\Filesystem.php on line 62
Fatal error: Exception thrown without a stack frame in Unknown on line 0
The above is from Win7/WAMP, but it’s the same on Ubuntu, php 5.3 in both cases.