Reputation: 3093
I know that ZendSearch in Zend Framework 2 is similar with Zend Search Lucene in Zend Framework 1.12. I've tried to use Zend Search Lucene with CodeIgniter 2.1.3. The indexing and finding process work well, but it still give some errors (warnings) like this:
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
That errors appear after I follow this article when I try to use Zend Search Lucene library in my codeigniter application. I doubt that the article and Zend Search Lucene is still valid when use with codeigniter 2.1.3 and now I want to use ZendSearch.
So, how to use ZendSearch with CodeIgniter 2.1.3?
Upvotes: 3
Views: 941
Reputation: 828
You have the Zend Search Lucene Library for the Codeigniter.
For Lucene search first you have to create index and then create index doc on which the actual search operation perform.
$index = Zend_Search_Lucene::create($CI->base_index_path . '/index_folder');
$doc = new Zend_Search_Lucene_Document();
and then add fields like this from your DB tables:
$doc->addField(Zend_Search_Lucene_Field::Keyword('id', $object->id));
$index->addDocument($doc);
And finally use as below, $q
is search parameter you want to search on this index.
$data['query'] = $q;
$query = "name:\"" . $q . "\" or full_desc:\"" . $q . "\"";
$query_result = $index->find($query);
Upvotes: 4