Discussion:
Zend_Search_Lucene : Boolean expression error
lekshmi
2008-05-14 05:43:55 UTC
Permalink
Hi,

I'm using zend 1.0.3. When I search for any phrase containing 'and' , I am
getting a fatal error
"Uncaught exception 'Zend_Search_Lucene_Search_QueryParserException' with
message 'Boolean expression error."

Suppose i'm searching for the words 'young and' and 'london' in field1.
The following is the code which i'm using:

$query = 'field1:young and AND field1:london';
Zend_Search_Lucene_Search_QueryParser::setDefaultOperator(1);
$userQuery = Zend_Search_Lucene_Search_QueryParser::parse($query);
$results = $index->find($userQuery);

Can someone please help me to solve this issue. It is very urgent. :-((

Thanks,
Lekshmi.
--
View this message in context: http://www.nabble.com/Zend_Search_Lucene-%3A-Boolean-expression-error-tp17223610p17223610.html
Sent from the Zend MFS mailing list archive at Nabble.com.
Alexander Veremyev
2008-05-15 10:44:32 UTC
Permalink
Hi,

1. Use Phrase syntax to search for sequence of two words:
--------------
$query = 'field1:"young and" AND field1:london';
// or 'field1:("young and" AND london)'
-------

2. Escape any char of the reserved word if you wont to search for it:
--------------
$query = 'field1:(young AND \and AND London)';
-------

3. You can also use Query build API to construct query:
http://framework.zend.com/manual/en/zend.search.lucene.query-api.html


With best regards,
Alexander Veremyev.
-----Original Message-----
Sent: Wednesday, May 14, 2008 9:44 AM
Subject: [fw-formats] Zend_Search_Lucene : Boolean expression error
Hi,
I'm using zend 1.0.3. When I search for any phrase containing
'and'
, I am
getting a fatal error
"Uncaught exception 'Zend_Search_Lucene_Search_QueryParserException' with
message 'Boolean expression error."
Suppose i'm searching for the words 'young and' and 'london' in field1.
$query = 'field1:young and AND field1:london';
Zend_Search_Lucene_Search_QueryParser::setDefaultOperator(1);
$userQuery = Zend_Search_Lucene_Search_QueryParser::parse($query);
$results = $index->find($userQuery);
Can someone please help me to solve this issue. It is very urgent. :-((
Thanks,
Lekshmi.
--
http://www.nabble.com/Zend_Search_Lucene-
%3A-Boolean-expression-error-tp17223610p17223610.html
Sent from the Zend MFS mailing list archive at Nabble.com.
No virus found in this incoming message.
Checked by AVG.
14.05.2008 16:44
lekshmi
2008-05-20 04:41:46 UTC
Permalink
Hi Alexander,

Now 'Boolean expression error' problem is solved... Thanks a lot :-) ..
I would like to ask you one more question. Is there a way to search a word
or phrase having digits in between (for eg: OX2 8PX ) against a text field?
Currently i'm getting search results.. but results are not appropriate.. i
think all numbers in between are skipped. In zend search manual I have come
across a a custom analyzer.
http://framework.zend.com/manual/en/zend.search.lucene.extending.html
But I don't know where to include this file and what all procedures to be
followed. Is there any alternate way to solve this issue? Could you please
help me?

Thanks,
Lekshmi.
Post by Alexander Veremyev
Hi,
--------------
$query = 'field1:"young and" AND field1:london';
// or 'field1:("young and" AND london)'
-------
--------------
$query = 'field1:(young AND \and AND London)';
-------
http://framework.zend.com/manual/en/zend.search.lucene.query-api.html
With best regards,
Alexander Veremyev.
-----Original Message-----
Sent: Wednesday, May 14, 2008 9:44 AM
Subject: [fw-formats] Zend_Search_Lucene : Boolean expression error
Hi,
I'm using zend 1.0.3. When I search for any phrase containing
'and'
, I am
getting a fatal error
"Uncaught exception 'Zend_Search_Lucene_Search_QueryParserException'
with
message 'Boolean expression error."
Suppose i'm searching for the words 'young and' and 'london' in
field1.
$query = 'field1:young and AND field1:london';
Zend_Search_Lucene_Search_QueryParser::setDefaultOperator(1);
$userQuery = Zend_Search_Lucene_Search_QueryParser::parse($query);
$results = $index->find($userQuery);
Can someone please help me to solve this issue. It is very urgent.
:-((
Thanks,
Lekshmi.
--
http://www.nabble.com/Zend_Search_Lucene-
%3A-Boolean-expression-error-tp17223610p17223610.html
Sent from the Zend MFS mailing list archive at Nabble.com.
No virus found in this incoming message.
Checked by AVG.
14.05.2008 16:44
--
View this message in context: http://www.nabble.com/Zend_Search_Lucene-%3A-Boolean-expression-error-tp17223610p17333107.html
Sent from the Zend MFS mailing list archive at Nabble.com.
Loading...