如何使用 Zend_Search_Lucene 作为 Zend Framework 之外的独立组件?
How to use Zend_Search_Lucene as a separate component outside Zend Framework?
由于使用 optimize() 方法优化 Zend_Search_Lucene 索引文件需要几秒钟才能完成,我想创建一个 Cron Job 以便每天自动完成索引文件的优化过程。
但是我无法在 Zend Framework 之外单独使用 Zend_Search_Lucene 组件。
我正在使用 Zend Framework 1。
我已经创建了 Zend_Search_Lucene 索引文件。
我在 trunk>public>test.php
中单独编写了以下代码来优化我现有的 Zend_Search_Lucene 索引文件:
<?php
require_once ('../library/Zend/Search/Lucene.php');
// Open existing index
$index = Zend_Search_Lucene::open('../application/searchindex');
// Optimize index.
$index->optimize();
echo "Index Optimized";
echo "Total documents: ".$index->numDocs();
我收到以下错误:
Warning: require_once(Zend/Search/Lucene/Document/Html.php): failed to open stream: No such file or directory in C:\apache\htdocs\dezyre_oct\trunk\library\Zend\Search\Lucene.php on line 27
Fatal error: require_once(): Failed opening required 'Zend/Search/Lucene/Document/Html.php' (include_path='.;C:\php\pear') in C:\apache\htdocs\dezyre_oct\trunk\library\Zend\Search\Lucene.php on line 27
有人可以帮助在 Zend Framework 之外单独使用 Zend_Search_Lucene 组件吗?
您应该像下面这样设置您的 zend 库的包含路径
$path = '/var/www/lib/Zend';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
之后包括 Zend Loader 以使用 zend autoloader
require_once('Zend/Loader.php');
由于使用 optimize() 方法优化 Zend_Search_Lucene 索引文件需要几秒钟才能完成,我想创建一个 Cron Job 以便每天自动完成索引文件的优化过程。
但是我无法在 Zend Framework 之外单独使用 Zend_Search_Lucene 组件。
我正在使用 Zend Framework 1。
我已经创建了 Zend_Search_Lucene 索引文件。
我在 trunk>public>test.php
中单独编写了以下代码来优化我现有的 Zend_Search_Lucene 索引文件:
<?php
require_once ('../library/Zend/Search/Lucene.php');
// Open existing index
$index = Zend_Search_Lucene::open('../application/searchindex');
// Optimize index.
$index->optimize();
echo "Index Optimized";
echo "Total documents: ".$index->numDocs();
我收到以下错误:
Warning: require_once(Zend/Search/Lucene/Document/Html.php): failed to open stream: No such file or directory in C:\apache\htdocs\dezyre_oct\trunk\library\Zend\Search\Lucene.php on line 27
Fatal error: require_once(): Failed opening required 'Zend/Search/Lucene/Document/Html.php' (include_path='.;C:\php\pear') in C:\apache\htdocs\dezyre_oct\trunk\library\Zend\Search\Lucene.php on line 27
有人可以帮助在 Zend Framework 之外单独使用 Zend_Search_Lucene 组件吗?
您应该像下面这样设置您的 zend 库的包含路径
$path = '/var/www/lib/Zend';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
之后包括 Zend Loader 以使用 zend autoloader
require_once('Zend/Loader.php');