Zend_Search_Lucene_Exception – non-wildcard characters

on with Leave a reply

Error : At least 3 non-wildcard characters are required at the beginning of pattern

While I am using the Zend Lucene Search, I got the Zend exception as below. While Investigate the issue I found some inputs to  the search are very strange. Strings are having the special characters at the beginning and ending of the strings. So that causes this exception. The problem solved by trimming the special characters from strings.

Fatal error: Uncaught exception ‘Zend_Search_Lucene_Exception’ with message ‘At least 3 non-wildcard characters are required at the beginning of pattern

Special character trimming from search strings

$special_characters='_$#@?!%=+';
 $qstring=trim($search_string, $special_characters);
$index = Zend_Search_Lucene::open(LUCENE_INDEX_PATH);
 Zend_Search_Lucene::setDefaultSearchField('search_field');
 $Query = Zend_Search_Lucene_Search_QueryParser::parse($qstring);
 $searchresults = $index->find($Query);

 

Best luck 🙂

Posted in PHP and tagged , by .

About Gowri

I am professional web developer with 4+ years experience. PHP, jQuery, WordPress, Magento and Symfony2 are my key skills in web development. I am working with strong enthusiastic team with spirit. We provide all web related solution like HTML/CSS development, Web graphic design and Logo.

Leave a Reply

Your email address will not be published. Required fields are marked *