2016-01-09 20 views
0

由于使用optimize()方法的Zend_Search_Lucene索引文件的优化过程需要几秒钟才能完成,因此我想创建一个Cron作业,以便每天自动完成索引文件的优化过程。如何使用Zend_Search_Lucene作为Zend Framework之外的独立组件?

但我不能在Zend Framework之外单独使用Zend_Search_Lucene组件。

我使用Zend框架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_Search_Lucene组件单独在Zend Framework之外?

回答

0

您应该设置包括像下面

$path = '/var/www/lib/Zend'; 
set_include_path(get_include_path() . PATH_SEPARATOR . $path); 

之后包括Zend的装载机使用的Zend自动加载你的Zend库的东西路径

require_once('Zend/Loader.php'); 

Basic Autoloader Usage