まず、次のものがインストールされていることを確認します。
- curl (パス環境変数に curl を追加したことを確認してください)
- 作曲
コマンド ラインで使用される php.ini で openssl が有効になっていることを確認します。(Windows で wamp を使用する場合、2 つの php ini ファイルがあります。1 つは apache 用で、もう 1 つはコマンド ライン用です。)
コマンド ラインを起動し、CD コマンドを使用して zend search を解凍したディレクトリに移動し、次の 2 つのコマンドを実行します。
カール -sh**ps://getcomposer.org/installer | php
php composer.phar インストール
同じディレクトリにphpファイルを作成し、.vendor/autoload.phpを含めます
さまざまなライブラリをロードする autoload 関数を作成します。現時点では、次のような簡単なものを書きました。
function autoload($classname) {
$path = __DIR . DS。「ライブラリ」.DS . $クラス名 . ".php";
if(file_exists($path)) {require_once($path);
} }
これにより、名前空間がわかっている場合、さまざまなクラスがロードされます。これは基本的なオートローダーであり、使用しないでください。
次のガイドを使用していますが、クラスの名前が次のように変更されているため、古くなっています。
$indexPath = 'C:\wamp\www\storage'; $index = ZendSearch\Lucene\Lucene::create($indexPath);
$doc = new ZendSearch\Lucene\Document();
$doc->addField(ZendSearch\Lucene\Document\Field::UnIndexed('url', $docUrl)); $doc->addField(ZendSearch\Lucene\Document\Field::UnIndexed('created', $docCreated)); $doc->addField(ZendSearch\Lucene\Document\Field::UnIndexed('teaser', $docTeaser)); $doc->addField(ZendSearch\Lucene\Document\Field::Text('title', $docTitle)); $doc->addField(ZendSearch\Lucene\Document\Field::Text('author', $docAuthor)); $doc->addField(ZendSearch\Lucene\Document\Field::UnStored('contents', $docBody));
$index->addDocument($doc); $index->commit();