1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| require_once ('Zend/Search/Lucene.php');
$index = new Zend_Search_Lucene('./donnees/mon-index', true);
$doc = new Zend_Search_Lucene_Document();
$docUrl1="E:/i3/www/Apache2/htdocs/helene/search/doc1.doc";
$docUrl2="E:/i3/www/Apache2/htdocs/helene/search/doc2.doc";
$docUrl3="E:/i3/www/Apache2/htdocs/helene/search/doc3.doc";
// Stocke l'URL du document pour l'identifier dans un résultat de recherche.
$doc->addField(Zend_Search_Lucene_Field::Text('url', $docUrl1));
$doc->addField(Zend_Search_Lucene_Field::Text('url', $docUrl2));
$doc->addField(Zend_Search_Lucene_Field::Text('url', $docUrl3));
$docContent1 = file_get_contents($docUrl1); //Lit tout un fichier dans une chaîne
$docContent2 = file_get_contents($docUrl2);
$docContent3 = file_get_contents($docUrl3);
// Contenu du document d'index
$doc->addField(Zend_Search_Lucene_Field::UnStored('contents', $docContent1));
$doc->addField(Zend_Search_Lucene_Field::UnStored('contents', $docContent2));
$doc->addField(Zend_Search_Lucene_Field::UnStored('contents', $docContent3));
$index->addDocument($doc);
$index->commit(); |
Partager