lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Minh Kama Yie" <m...@nuix.com.au>
Subject Re: performing NOT queries
Date Thu, 08 Aug 2002 08:35:04 GMT
Hi Nader,

Thanks for the quick reply!

Yeah, I read that in the javadoc, but the FAQ seems to say otherwise (it
says to set both prohibited AND required flags).

I have also tried setting only the prohibited flag (as you are suggesting)
but that doesn't return any results either. I have also tried using
QueryParser. I simply added "NOT " in front of my term. That didn't work
either.

I am correct in assuming that my intended NOT query will return 5 rows?

Thanks again.

----- Original Message -----
From: "Nader S. Henein" <nsh@bayt.net>
To: "Lucene Users List" <lucene-user@jakarta.apache.org>
Sent: Thursday, August 08, 2002 6:32 PM
Subject: RE: performing NOT queries


> in the Lucene JAVADOC you see this :
> /*
> public final void add(Query query,
>                       boolean required,
>                       boolean prohibited)Adds a clause to a boolean query.
> Clauses may be:
> required which means that documents which do not match this sub-query will
> not match the boolean query;
> prohibited which means that documents which do match this sub-query will
not
> match the boolean query; or
> neither, in which case matched documents are neither prohibited from nor
> required to match the sub-query.
>
> It is an error to specify a clause as both required and prohibited.
> */
>
> and you see that the last line states that "It is an error to specify a
> clause as both required and prohibited."
> so you can't so that, you need to think of these as on/off flags rather
than
> true and false from the boolean sense.
>
> so in your second query try :
>
> instead of this:
>
> BooleanQuery query = new BooleanQuery();
> query.add(QueryParser.parse("myValue", mFieldName, myAnalyzer), true,
true)
>
> try this:
>
> BooleanQuery query = new BooleanQuery();
> query.add(QueryParser.parse("myValue", mFieldName, myAnalyzer), false,
true)
>
> I hope this works, but by the way there are easier ways of doing a NOT,
> check out the queryParser section of the JavaDocs
>
> Nader Henein
>
> -----Original Message-----
> From: Minh Kama Yie [mailto:minh@nuix.com.au]
> Sent: Thursday, August 08, 2002 11:17 AM
> To: lucene-user@jakarta.apache.org
> Subject: performing NOT queries
>
>
> Hi all,
>
> I'm relatively new to Lucene so this question may seem a little obvious
but
> I'm having some problems which may be a result of a misunderstanding on my
> part.
>
> A description of my problem is as follows:
>
> I have indexed 30 documents and then create a BooleanQuery as follows:
>
> BooleanQuery query = new BooleanQuery();
> query.add(QueryParser.parse("myValue", myFieldName, myAnalyzer), true,
> false);
>
> I then execute it against the indexes and receive 25 documents back.
>
> So I was to then execute the a boolean query constructed like:
>
> BooleanQuery query = new BooleanQuery();
> query.add(QueryParser.parse("myValue", mFieldName, myAnalyzer), true,
true);
>
> I _should_ get the other 5 right?
>
> Am I missing something here?
>
> Thanks in advance guys, you guys do awesome work.
>
> Regards,
>
> Minh Kama Yie
>
> This message is intended only for the named recipient.
> If you are not the intended recipient you are notified that
> disclosing, copying, distributing or taking any action
> in reliance on the contents of this information is strictly
> prohibited.
>
>
> --
> To unsubscribe, e-mail:
<mailto:lucene-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
<mailto:lucene-user-help@jakarta.apache.org>


--
To unsubscribe, e-mail:   <mailto:lucene-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-user-help@jakarta.apache.org>


Mime
View raw message