Problem with Zend Lucene

For programming and general questions on Zend Framework

Problem with Zend Lucene

Postby screamsmurf on Fri Jul 13, 2012 5:31 pm

Hi everybody,
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.
screamsmurf
 
Posts: 3
Joined: Fri Jul 13, 2012 5:18 pm

Re: Problem with Zend Lucene

Postby screamsmurf on Sun Jul 29, 2012 12:42 am

Up the thread ^^.
Nobody can help me?
screamsmurf
 
Posts: 3
Joined: Fri Jul 13, 2012 5:18 pm

Re: Problem with Zend Lucene

Postby us2rn4m2 on Sun Jul 29, 2012 4:39 am

Hi,
foreach() inside for() , it is really necessary ?

Try:
Put your foreach() outside.
us2rn4m2
 
Posts: 48
Joined: Mon Jun 18, 2012 12:41 am

Re: Problem with Zend Lucene

Postby screamsmurf on Tue Jul 31, 2012 11:51 am

OK thanks for your reply.

When i'm removed the first loop, i've the same result : Too Many Open Files.
The GNU/Linux who have running the script parameted the open files to 35.
screamsmurf
 
Posts: 3
Joined: Fri Jul 13, 2012 5:18 pm


Return to Zend Framework

Who is online

Users browsing this forum: marc2559 and 5 guests