Created
January 20, 2011 17:05
-
-
Save harikt/788192 to your computer and use it in GitHub Desktop.
Located at controllers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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