I use symfony with Zend Lucene Search. I have
$query = Zend_Search_Lucene_Search_QueryParser::parse($query.'*');
$hits = self::getLuceneIndex()->find($query);
Sometimes I have error :
At least 3 non-wildcard characters are required at the beginning of pattern.
When I make like in documentations:
$pattern = new Zend_Search_Lucene_Index_Term($query.'*');
$query = new Zend_Search_Lucene_Search_Query_Wildcard($pattern);
$hits = self::getLuceneIndex()->find($query);
It finds nothing.
I do not is it right , but it is work for me :
So, query fail in my case, because it have < 3 characters or have some special characters, so in my search action :
public function executeAds(sfWebRequest $request)
{
if (!$query = $request->getParameter('query'))
{
return $this->forward('search', 'adssearch');
}
$query = str_replace(" ", "", $query);
$query = preg_replace("/[^A-Za-z0-9]/","",$query);
if (strlen(trim($query))<3)
{
$this->redirect('search/notice');
}
$this->ads = Doctrine_Core::getTable('Ads') ->getAdsLuceneQuery($query);
I do not use
$pattern = new Zend_Search_Lucene_Index_Term($query.'*');
$query = new Zend_Search_Lucene_Search_Query_Wildcard($pattern);
$hits = self::getLuceneIndex()->find($query);
Because it is not work for me.