You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by "Kulkarni, Ajit Kamalakar" <aj...@ptc.com> on 2009/01/06 10:40:15 UTC
Query about NOT (-) operator
Hi,
The query
1. NOT(IBA60019_l:1) AND NOT(IBA60019_l:0) AND
businessType:wt.doc.WTDocument
works
But below query does not work
2. (NOT(IBA60019_l:1) AND NOT(IBA60019_l:0)) AND
businessType:wt.doc.WTDocument
Query number 1 shows the records but Query number 2 does not show any
records
3. (NOT(IBA60019_l:1) OR NOT(IBA60019_l:0)) AND
businessType:wt.doc.WTDocument
The Query no 3 also does not show any records where as it should show
all the records for which businessType is wt.doc.WTDocument
4. NOT(IBA60019_l:1) OR NOT(IBA60019_l:0) AND
businessType:wt.doc.WTDocument
Query number 4 works as if it is query number 1 i.e. OR is working as
AND
Can someone comment on this?
Thanks,
Ajit
Re: Query about NOT (-) operator
Posted by Chris Hostetter <ho...@fucit.org>.
: But below query does not work
: 2. (NOT(IBA60019_l:1) AND NOT(IBA60019_l:0)) AND
: businessType:wt.doc.WTDocument
boolean queries must have at least one "positive" expression (ie; MUST or
SHOULD) in order to match. the solr query parser tries to help with this
and if the *outermost* BooleanQuery doesn't contains only negatived
clauses, it adds a match all docs query (ie: *:*) ... but in your case,
you have a nested booleanquery which contains only negated clauses ... so
you need to included the match all docs query explicitly...
+(*:* -IBA60019_l:1 -IBA60019_l:0) +businessType:wt.doc.WTDocument
-Hoss