I want to use Zend Lucene to add searching functions to my website and I have a problem.
When I want to create index for a mysql table i've got an PHP Error : "Too many open files", but when i'm looking my index folder, i've only 6 files!
My table contains only 4 records and my php code to create index is :
- Code: Select all
// start
$currentIndex = utils::getLuceneIndex();
Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Text());
// get total fiche
$totalFiche = FichePeer::doCount(new Criteria());
$docBySegment = 10;
// for every segment, do...
for($i=0; $i<$totalFiche; $i+=$docBySegment) {
// select all fiches for the current segment
$c = new Criteria();
$c->add(FichePeer::ID, $i , Criteria::GREATER_EQUAL);
$c->add(FichePeer::ID, $i+$docBySegment, Criteria::LESS_EQUAL);
$fiches = FichePeer::doSelect($c);
foreach ($fiches as $fiche) {
$doc = new Zend_Search_Lucene_Document();
$doc->addField(Zend_Search_Lucene_Field::Keyword('pk', $fiche->getId()));
$nameField = Zend_Search_Lucene_Field::Text('lastname', $fiche->getLastName(), 'utf-8');
$nameField->boost = 10;
$doc->addField($nameField);
$doc->addField(Zend_Search_Lucene_Field::Text('firstname', $fiche->getFirstName(), 'utf-8'));
$doc->addField(Zend_Search_Lucene_Field::Text('service', $fiche->getService()->getLibelleService(), 'utf-8'));
$doc->addField(Zend_Search_Lucene_Field::Text('fonction' , $fiche->getFonction(), 'utf-8'));
$doc->addField(Zend_Search_Lucene_Field::Text('competence', $fiche->getSkills(), 'utf-8'));
// add job to the index
$currentIndex->addDocument($doc);
$doc = null;
}
$currentIndex->commit();
}
$currentIndex->optimize();
// end
When i try to open 1000 files with fopen and without fclose, i've not this problem! Can you help me?
Sorry for my english,
Thanks,
Julien.

