The query parser may generate two types of exceptions:
Zend_Search_Lucene_Exceptionis thrown if something goes wrong in the query parser itself.Zend_Search_Lucene_Search_QueryParserExceptionis thrown when there is an error in the query syntax.
It's a good idea to catch
Zend_Search_Lucene_Search_QueryParserExceptions and handle them
appropriately:
<?php
try {
$query = Zend_Search_Lucene_Search_QueryParser::parse($queryString);
} catch (Zend_Search_Lucene_Search_QueryParserException $e) {
echo "Query syntax error: " . $e->getMessage() . "\n";
}
The same technique should be used for the find() method of a
Zend_Search_Lucene object.
Starting in 1.5, query parsing exceptions are suppressed by default. If query doesn't
conform query language, then it's tokenized using current default analyzer and all
tokenized terms are used for searching. Use
Zend_Search_Lucene_Search_QueryParser::dontSuppressQueryParsingExceptions()
method to turn exceptions on.
Zend_Search_Lucene_Search_QueryParser::suppressQueryParsingExceptions()
and
Zend_Search_Lucene_Search_QueryParser::queryParsingExceptionsSuppressed()
methods are also intended to manage exceptions handling behavior.




