Zend_Lucene error
I'm new on using Zend framework. I wanted to use Zend_Lucene to achieve a small books engine on my web site. I downloaded the Full package and included it into my Netbeans 7 and it's went fine, then, I read the get started tutorial of the official site of Zend_Lucene, I could do the indexing but with some errors: Here is my code:
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();
These file have been created: And here is the error: _0.cfs, segments_2, optimization.lock.file, read.lock.file, read-lock-processing.lock.file, write.lock.file and segments.gen.
And this is the error appears after running my code and creating the indexer:
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\Storag开发者_运维百科e\Directory\Filesystem.php on line 349
I read that this requires including the library into my include_path, I sneaked around my Netbeans and I thought that I got it, here a screenshot:
Please support my issue, I need it for a graduating project! Thanks in advance! Regards!Do not use this 'Global Include Path' in Netbeans. Use set_include_path() function instead in your starting php file (index.php).
I just had a similiar issue and got no idea why Zend_Lucene just would not work. It always came up with
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
the problem was, my include path (set_include_path
) caused that issue as I had provided only a relative link to the Zend Framework.
I solved this problem by specifying an absolute path to the Zend Framework Library -- so my smallest code sample to see if Lucene runs is as follows:
<?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');
?>
精彩评论