Parenthesis in query string

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Parenthesis in query string

Tommaso Teofili
Hi all,
I've just noticed a strange behavior (or, at least, I didn't expect that),
when adding useless parenthesis to a query.
Using the lucene query parser in Solr I get no results with the query:

* ((( NOT (text:"something"))) AND date <= 2010-12-15) *

while I get the expected results when the query is :

*( NOT (text:"something") AND date <= 2010-12-15) *

Setting the debugQuery=true param I get this for the first query sample:
<str name="rawquerystring">
((( NOT (text:"something"))) AND data <= 2010-12-15)
</str>
<str name="querystring">
((( NOT (text:"something"))) AND data <= 2010-12-15)
</str>
<str name="parsedquery">
+(-PhraseQuery(text:"something")) +text:dat PhraseQuery(text:"2010 12 15")
</str>
<str name="parsedquery_toString">
+(-text:"something") +text:dat text:"2010 12 15"
</str>

while I get the following in the second (right) query sample:
<str name="rawquerystring">
( NOT (text:"something") AND data <= 2010-12-15)
</str>
<str name="querystring">
( NOT (text:"something") AND data <= 2010-12-15)
</str>
<str name="parsedquery">
-PhraseQuery(text:"something") +text:dat PhraseQuery(text:"2010 12 15")
</str>
<str name="parsedquery_toString">
-text:"something" +text:dat text:"2010 12 15"
</str>

Is that something expected and I am missing something or it's a bug?
Thanks in advance.
Regards,
Tommaso
Reply | Threaded
Open this post in threaded view
|

Re: Parenthesis in query string

iorixxx
I think this is related to http://search-lucene.com/m/lM9CXH2Pl7

Also as explained here http://search-lucene.com/m/g4JmKSGMaI/ 
it is better to use + - operator rather than OR AND NOT parenthesis.

http://wiki.apache.org/lucene-java/BooleanQuerySyntax

Just for your information: There is no such syntax 'date <= 2010-12-15' that returns documents having date less than or equal to 2010-12-15.


--- On Wed, 12/15/10, Tommaso Teofili <[hidden email]> wrote:

> From: Tommaso Teofili <[hidden email]>
> Subject: Parenthesis in query string
> To: [hidden email]
> Date: Wednesday, December 15, 2010, 7:24 PM
> Hi all,
> I've just noticed a strange behavior (or, at least, I
> didn't expect that),
> when adding useless parenthesis to a query.
> Using the lucene query parser in Solr I get no results with
> the query:
>
> * ((( NOT (text:"something"))) AND date <= 2010-12-15)
> *
>
> while I get the expected results when the query is :
>
> *( NOT (text:"something") AND date <= 2010-12-15) *
>
> Setting the debugQuery=true param I get this for the first
> query sample:
> <str name="rawquerystring">
> ((( NOT (text:"something"))) AND data <= 2010-12-15)
> </str>
> <str name="querystring">
> ((( NOT (text:"something"))) AND data <= 2010-12-15)
> </str>
> <str name="parsedquery">
> +(-PhraseQuery(text:"something")) +text:dat
> PhraseQuery(text:"2010 12 15")
> </str>
> <str name="parsedquery_toString">
> +(-text:"something") +text:dat text:"2010 12 15"
> </str>
>
> while I get the following in the second (right) query
> sample:
> <str name="rawquerystring">
> ( NOT (text:"something") AND data <= 2010-12-15)
> </str>
> <str name="querystring">
> ( NOT (text:"something") AND data <= 2010-12-15)
> </str>
> <str name="parsedquery">
> -PhraseQuery(text:"something") +text:dat
> PhraseQuery(text:"2010 12 15")
> </str>
> <str name="parsedquery_toString">
> -text:"something" +text:dat text:"2010 12 15"
> </str>
>
> Is that something expected and I am missing something or
> it's a bug?
> Thanks in advance.
> Regards,
> Tommaso
>