Abhay,

This query is processed by the query parser...

((+SEARCH_NAME:dvd +SEARCH_NAME:cd ) OR (+DEF_DOC_FIELD:dvd 
+DEF_DOC_FIELD:cd )) AND ((-SEARCH_NAME:player) OR (-DEF_DOC_F
IELD:player))

and comes out looking like...
+((+SEARCH_NAME:dvd +SEARCH_NAME:cd) (+DEF_DOC_FIELD:dvd +DEF_DOC_FIELD:cd)) 
++((-SEARCH_NAME:player) (-DEF_DOC_FIELD:player))
Using org.apache.lucene.search.Query.toString(String fieldName)

I use this representation as it shows me what happened after my query was processed by 
the QueryParser and Analyzer, so stop words would be removed and case modified if the 
analyzer does such things.


This part...
+((+SEARCH_NAME:dvd +SEARCH_NAME:cd) (+DEF_DOC_FIELD:dvd +DEF_DOC_FIELD:cd))
will produce a set of documents as hits that have the "dvd" and "cd" terms in those 
fields

This part...
+((-SEARCH_NAME:player) (-DEF_DOC_FIELD:player))
will always produce an empty set

when the two sets are joined with an intersection, you will always get an empty set

The problem is that when using NOT or - operator, it excludes documents from the set 
of found documents not the set of all documents. This is correct Lucene behavior. So, 
since their are no found documents in that required part of the query, your results 
will always be no hits.

This is mentioned in the jGuru FAQ at http://www.jguru.com/faq/view.jsp?EID=593598

Rearranging the query the way you mentioned is the correct way to deal with this.

Eric

-----Original Message-----
From: Abhay Saswade [mailto:[EMAIL PROTECTED]]
Sent: Friday, January 03, 2003 9:07 PM
To: [EMAIL PROTECTED]
Subject: Re: Query grouping
...

However, when I try to do this in a single query by grouping I get no result
((+SEARCH_NAME:dvd +SEARCH_NAME:cd ) OR (+DEF_DOC_FIELD:dvd 
+DEF_DOC_FIELD:cd )) AND ((-SEARCH_NAME:player) OR (-DEF_DOC_F
IELD:player))

I don't get any results on a single term query like this (and this explains 
why I am not getting any results in above query)
-SEARCH_NAME:player
Is this a known issue?

Is there any way of dealing with above-mentioned problem other than 
rearranging query like this?
(+SEARCH_NAME:dvd +SEARCH_NAME:cd -SEARCH_NAME:player) OR 
(+DEF_DOC_FIELD:dvd +DEF_DOC_FIELD:cd -DEF_DOC_FIELD:player)

Thanks
Abhay






>From: Otis Gospodnetic <[EMAIL PROTECTED]>
>Reply-To: "Lucene Users List" <[EMAIL PROTECTED]>
>To: Lucene Users List <[EMAIL PROTECTED]>
>Subject: Re: Query grouping
>Date: Fri, 3 Jan 2003 12:33:53 -0800 (PST)
>
>Does the '... AND -.....' part even make sense?
>Why not just .... -.... ?
>Also, .... AND +.... doesn't make sense, does it?
>+<field>:<term> means the term has to be in the result, so AND is not
>really needed, is it?
>I am not sure if spaces after 'SEARCH_NAME:' make a difference or not
>
>Also, field:term1 field:term2 implies term1 OR term2, so no need for OR
>there, especially with +, I think.
>
>Otis
>
>
>--- Abhay Saswade <[EMAIL PROTECTED]> wrote:
> > I am using lucene release 1.2. I am using StandardAnalyzer. Have
> > anybody
> > faced this problem?
> >
> > I get same results when I run following queries
> >
> > 1. (+SEARCH_NAME:jhon  +SEARCH_NAME:joy)  AND -SEARCH_NAME:chan
> > 2. (+SEARCH_NAME:jhon  AND +SEARCH_NAME: joy)  AND -SEARCH_NAME:chan
> > 3. (+SEARCH_NAME:jhon  OR +SEARCH_NAME: joy)  AND -SEARCH_NAME:chan
> >
> > But when I regroup the query by putting brackets around the last term
> > like
> > mentioned below I don't get any results
> >
> > 1. (+SEARCH_NAME:jhon +SEARCH_NAME: joy)  AND (-SEARCH_NAME:chan)
> > 2. (+SEARCH_NAME:jhon AND +SEARCH_NAME: joy)  AND (-SEARCH_NAME:chan)
> > 3. (+SEARCH_NAME:jhon OR +SEARCH_NAME: joy)  AND (-SEARCH_NAME:chan)
> >
> > This is just an example. I need to do grouping on various fields. Am
> > I
> > missing something?  Is there any document other than
> > http://jakarta.apache.org/lucene/docs/queryparsersyntax.html? Can
> > somebody
> > throw some light on this?
> >
> > Thanks,
> > Abhay
> >
> >
> >
> >
> >
> >
> > _________________________________________________________________
> > MSN 8 with e-mail virus protection service: 2 months FREE*
> > http://join.msn.com/?page=features/virus
> >
> >
> > --
> > To unsubscribe, e-mail:
> > <mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail:
> > <mailto:[EMAIL PROTECTED]>
> >
>
>
>__________________________________________________
>Do you Yahoo!?
>Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
>http://mailplus.yahoo.com
>
>--
>To unsubscribe, e-mail:   
><mailto:[EMAIL PROTECTED]>
>For additional commands, e-mail: 
><mailto:[EMAIL PROTECTED]>


_________________________________________________________________
Add photos to your e-mail with MSN 8. Get 2 months FREE*. 
http://join.msn.com/?page=features/featuredemail


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to