addField(Zend_Search_Lucene_Field::Text('path', $fileName)); $this->addField(Zend_Search_Lucene_Field::Keyword( 'modified', filemtime($fileName) )); $f = fopen($fileName,'rb'); $byteCount = filesize($fileName); $data = ''; while ( $byteCount > 0 && ($nextBlock = fread($f, $byteCount)) != false ) { $data .= $nextBlock; $byteCount -= strlen($nextBlock); } fclose($f); if ($storeContent) { $this->addField(Zend_Search_Lucene_Field::Text('contents', $data, 'ISO8859-1')); } else { $this->addField(Zend_Search_Lucene_Field::UnStored('contents', $data, 'ISO8859-1')); } } } // Create index $index = new Zend_Search_Lucene('index', true); // Uncomment next line if you want to have case sensitive index // ZSearchAnalyzer::setDefault(new ZSearchTextAnalyzer()); setlocale(LC_CTYPE, 'en_US'); $indexSourceDir = 'IndexSource'; $dir = opendir($indexSourceDir); while (($file = readdir($dir)) !== false) { if (is_dir($indexSourceDir . '/' . $file)) { continue; } if (strcasecmp(substr($file, strlen($file)-5), '.html') != 0) { continue; } // Create new Document from a file $doc = new FileDocument($indexSourceDir . '/' . $file, true); // Add document to the index $index->addDocument($doc); echo $file . "...\n"; flush(); } closedir($dir);