3

我知道Zend Framework 2中的ZendSearch與Zend Search Lucene中的Zend Framework 1.12類似。我試過在CodeIgniter 2.1.3中使用Zend Search Lucene。索引和查找過程很好地工作,但它還是給了一些錯誤(警告)這樣的:如何在CodeIgniter 2.1.3中使用ZendSearch?

Warning: include(application/errors/error_php.php) [function.include]: failed to open stream: No such file or directory in C:\path\to\system\core\Exceptions.php on line 182 
Warning: include() [function.include]: Failed opening 'application/errors/error_php.php' for inclusion (include_path='.;C:\php5\pear;application/libraries') in C:\path\to\system\core\Exceptions.php on line 182 
Fatal error: require_once() [function.require]: Failed opening required 'Zend/Search/Lucene/Storage/File/Filesystem.php' (include_path='.;C:\php5\pear;application/libraries') in C:\path\to\application\libraries\Zend\Search\Lucene\Storage\Directory\Filesystem.php on line 349 

那我跟着this article後,當我試圖在我的笨應用程序中使用的Zend的Lucene搜索庫中出現錯誤。我懷疑這篇文章和Zend Search Lucene在與codeigniter 2.1.3一起使用時仍然有效,現在我想使用ZendSearch。

那麼,如何在CodeIgniter 2.1.3中使用ZendSearch?

+1

你能發佈您的代碼的要點,這樣它可能有很大幫助分析問題出在哪裏 –

+0

我的代碼是相同與上面鏈接的文章。我以前從未使用過Zend。我曾經使用CI。有沒有我錯過的配置? –

回答

4

你有Zend搜索Codeigniter的Lucene庫。

對於Lucene搜索首先,您必須創建索引,然後創建實際搜索操作執行的索引文檔。

$index = Zend_Search_Lucene::create($CI->base_index_path . '/index_folder'); 

$doc = new Zend_Search_Lucene_Document(); 

,然後從數據庫表中添加這樣的字段:

$doc->addField(Zend_Search_Lucene_Field::Keyword('id', $object->id)); 

$index->addDocument($doc); 

最後如下使用,$q是要在這個索引搜索的搜索參數。

$data['query'] = $q; 
$query = "name:\"" . $q . "\" or full_desc:\"" . $q . "\""; 
$query_result = $index->find($query);