0

I'm using Zend_Search_Lucene, in a standalone project not based on ZF. I index content successfully, and search them also, but the problem is that it cannot create the .fnm files

here is the code I am using

Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8());
Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding('utf-8');
Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8_CaseInsensitive());

$this->index = Zend_Search_Lucene::create(self::PATH_INDEX);

$doc = new Zend_Search_Lucene_Document();

$doc->addField(Zend_Search_Lucene_Field::keyword('id',$content['id'],'UTF-8'));
$doc->addField(Zend_Search_Lucene_Field::text('summary',$summary,'UTF-8'));
$doc->addField(Zend_Search_Lucene_Field::keyword('module',$module,'UTF-8'));

$this->index->addDocument($doc);

I have also tried

$doc->addField(Zend_Search_Lucene_Field::keyword('module',utf_encode($module),'UTF-8'));

My content is searchable but I dunno why it doesn't create the fnm files, it creates the rest like cfs files and fdx, locks, segments ...etc so it's not a directory or permissions problem, the problem is with the locks I guess.

Here is the exception

Fatal error: Uncaught exception 'Zend_Search_Lucene_Exception' with message 'fopen(dict/_1.fnm): failed to open stream: No such file or directory' in Zend/Search/Lucene/Storage/File/Filesystem.php on line 67

Zend_Search_Lucene_Exception: fopen(dict/_1.fnm): failed to open stream: No such file or directory in Zend/Search/Lucene/Storage/File/Filesystem.php on line 67

Call Stack:
    0.0882    7819976   1. Zend_Search_Lucene_Proxy->__destruct() Zend/Search/Lucene/Proxy.php:0
    0.0882    7819976   2. Zend_Search_Lucene->removeReference() Zend/Search/Lucene/Proxy.php:63
    0.0882    7819976   3. Zend_Search_Lucene->_close() Zend/Search/Lucene.php:607
    0.0882    7819976   4. Zend_Search_Lucene->commit() Zend/Search/Lucene.php:569
    0.0882    7819976   5. Zend_Search_Lucene_Index_Writer->commit() Zend/Search/Lucene.php:1419
    0.0882    7819976   6. Zend_Search_Lucene_Index_SegmentWriter_DocumentWriter->close() Zend/Search/Lucene/Index/Writer.php:757
    0.0882    7819976   7. Zend_Search_Lucene_Index_SegmentWriter->_dumpFNM() Zend/Search/Lucene/Index/SegmentWriter/DocumentWriter.php:212
    0.0882    7820112   8. Zend_Search_Lucene_Storage_Directory_Filesystem->createFile(???) Zend/Search/Lucene/Index/SegmentWriter.php:280
    0.0882    7820912   9. Zend_Search_Lucene_Storage_File_Filesystem->__construct(???, ???) Zend/Search/Lucene/Storage/Directory/Filesystem.php:184

Anyhelp will be really appreciated

Omar
  • 8,374
  • 8
  • 39
  • 50
  • Did you intentionally leave out the rest of the exception message? There should be relevant text after the colon `fopen(indecies/_1.fnm):` as to why `fopen()` failed. – Mike B Apr 25 '12 at 20:33
  • @MikeB updated with the stack trace – Omar Apr 25 '12 at 20:35
  • If it would of any help, I have debugged the __construct() method in Zend_Search_Lucene_Storage_File_Filesystem which creates the file, it first create _0.fnm successfully, but then tries to create the _1.fnm and fails, although both on the same directory with the same mode 'w+b' the only difference is the filename. @MikeB – Omar Apr 25 '12 at 20:42
  • Any chance you could print the params of that construct method with pass/fail? Something like `$filename=dict/_0.fnm, $mode='r+b', success`, `$filename=dict/_1.fnm, $mode='r+b', fail`.. I can't recreate this or I'd debug it myself. Once you nail it down to the params.. try to do it yourself with a new file in the same directory that only tries to do something like ` – Mike B Apr 25 '12 at 20:49
  • success: $filename='dict/_0.fnm',$mode='w+b', fail: $filename='dict/_1.fnm',$mode='w+b' @MikeB I'll try fopen with the same params, I had also checked the permissions on dict before creating the _1.fnm and its the same rwx – Omar Apr 25 '12 at 20:59
  • It has nothing to do with fopen, tried it separately and it worked :S with just the same parameters – Omar Apr 25 '12 at 21:15

1 Answers1

0

Worked finally after making the directory to absolute.

Omar
  • 8,374
  • 8
  • 39
  • 50