0

我是使用 Zend 框架的新手。我想用 Zend_Lucene 在我的网站上实现一个小型图书引擎。我下载了完整包并将其包含在我的 Netbeans 7 中,一切正常,然后,我阅读了 Zend_Lucene 官方网站的入门教程,我可以进行索引,但有一些错误:这是我的代码:

require_once('ZendFramework-1.11.7/library/Zend/Search/Lucene.php');
$indexPath = 'C:\wamp\www\witswork\Documents';
$index = Zend_Search_Lucene::create($indexPath);

$index = Zend_Search_Lucene::open($indexPath);

$query = new Zend_Search_Lucene_Search_Query_MultiTerm();
$doc = new Zend_Search_Lucene_Document();
$doc->addField(Zend_Search_Lucene_Field::UnIndexed('url', "Plan.docx"));
$doc->addField(Zend_Search_Lucene_Field::Text('title', "Plan"));

$hits = $index->find($query);
$index->addDocument($doc);
$index->commit();

这些文件已创建:这里是错误:_0.cfs、segments_2、optimization.lock.file、read.lock.file、read-lock-processing.lock.file、write.lock.file 和segments.gen。

这是运行我的代码并创建索引器后出现的错误:

Warning: require_once(Zend/Search/Lucene/Storage/File/Filesystem.php) [function.require-once]: failed to open stream: No such file or directory in C:\wamp\www\witswork\Zend\Search\Lucene\Storage\Directory\Filesystem.php on line 349

Fatal error: require_once() [function.require]: Failed opening required 'Zend/Search/Lucene/Storage/File/Filesystem.php' (include_path='.;C:\php5\pear;ZendFramework-1.11.7/library/Zend') in C:\wamp\www\witswork\Zend\Search\Lucene\Storage\Directory\Filesystem.php on line 349

我读到这需要将库包含到我的 include_path 中,我在我的 Netbeans 周围偷偷摸摸,我认为我明白了,这里是截图: 在此处输入图像描述 请支持我的问题,我需要它用于毕业项目!提前致谢!问候!

4

2 回答 2

0

我只是有一个类似的问题,不知道为什么 Zend_Lucene 不起作用。它总是想出

Warning: require_once(Zend/Search/Lucene/Storage/File/Filesystem.php) [function.require-once]: failed to open stream: No such file or directory in C:\wamp\www\witswork\Zend\Search\Lucene\Storage\Directory\Filesystem.php on line 349

问题是,我的包含路径 ( set_include_path) 导致了这个问题,因为我只提供了 Zend 框架的相对链接。

我通过指定 Zend 框架库的绝对路径解决了这个问题——所以我查看 Lucene 是否运行的最小代码示例如下:

<?php

$zendPath = realpath('../_lib/ZendFramework-1.11.11/library/');

set_include_path($zendPath.PATH_SEPARATOR.get_include_path());
include 'Zend/Loader/Autoloader.php';
Zend_Loader_Autoloader::getInstance(); 

$index = Zend_Search_Lucene::create('test');

?>
于 2011-12-29T14:45:43.773 回答
0

不要在 Netbeans 中使用此“全局包含路径”。在您的起始 php 文件 (index.php) 中使用 set_include_path() 函数。

于 2011-06-23T15:55:37.597 回答