Created
December 5, 2011 04:24
-
-
Save dpdexter/1432288 to your computer and use it in GitHub Desktop.
_search_index
This file contains 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
function _search_index($queryStr){ | |
// Need at least 3 characters for wildcard searches | |
if(strlen($queryStr) >= 3){ | |
// Dashes don't play nicely with our wildcard search | |
$queryStr = str_replace("-"," ",$queryStr).'*'; | |
} | |
ini_set('include_path',ini_get('include_path').PATH_SEPARATOR.PATH_THIRD.'brilliant_retail'.DIRECTORY_SEPARATOR.'core'.DIRECTORY_SEPARATOR.'library'.DIRECTORY_SEPARATOR.PATH_SEPARATOR); | |
include_once(PATH_THIRD.'brilliant_retail'.DIRECTORY_SEPARATOR.'core'.DIRECTORY_SEPARATOR.'library'.DIRECTORY_SEPARATOR.'Zend'.DIRECTORY_SEPARATOR.'Search'.DIRECTORY_SEPARATOR.'Lucene.php'); | |
Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_TextNum_CaseInsensitive()); | |
$path = APPPATH.'cache/brilliant_retail/search'; | |
$index = Zend_Search_Lucene::open($path); | |
$query = Zend_Search_Lucene_Search_QueryParser::parse($queryStr, 'utf-8'); | |
$hits = $index->find($query); | |
return $hits; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment