Skip to content

Instantly share code, notes, and snippets.

@harikt
Created January 20, 2011 17:05
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save harikt/788192 to your computer and use it in GitHub Desktop.
Located at controllers
<?php
namespace app\controllers;
use \app\models\Search,
\Zend_Search_Lucene;
class SearchesController extends \lithium\action\Controller {
/*
* Called when a search happens. Here we assume the method type of form is get,
* else use ->data instead of ->query.
*/
public function index() {
/*
*Same path where we have created the index.
*/
$index = new Zend_Search_Lucene( __DIR__ . '/../data/search');
$query = $this->request->query['query'];
$searches = $index->find($query);
return compact('index', 'query', 'searches');
}
/*
* More details about Zend_Search_Lucene visit
* http://framework.zend.com/manual/en/zend.search.lucene.html
* This function just makes index and store files in a directory.
*/
public function makeindex() {
$search = new Search();
$search->makeindex();
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment