lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From javier muguruza <jmugur...@gmail.com>
Subject Re: MatchAllDocsQuery with BooleanClause.Occur.MUST_NOT
Date Tue, 20 Dec 2005 18:15:05 GMT
The double negatives are a byproduct of my code building the query, as
the user has several fields to choose from etc, it is not done on
purpose.

With luke I was able to see that:
+body:memo 1 hit
+body:memo -body:policy 0
+body:memo -(-body:policy) 1
+body:memo +(-body:policy) 0
In the last two cases, if I substitute policy by a non-existant word
(policy is in the index) I get the same results, so the extra -() is
screwing the query. For my previous tests while coding I noticed
(wrongly) the extra -() was harmless...my bad.

I have refactored my code so extra -() are avoided, now everything is
running ok,

thanks,
javier

On 12/20/05, Yonik Seeley <yseeley@gmail.com> wrote:
> I'm not sure I understand the purpose of the double negatives.
> Also, a boolean query must have some non-prohibited clauses to match
> anything (and mydocs in your code example violates this).
>
> Is the following what you are trying to do?
>
> BooleanQuery mbq = new BooleanQuery();
> TermQuery mydocs = body:darpa query;
> MatchAllDocsQuery alldocs = new MatchAllDocsQuery();
> mbq.add(mydocs , BooleanClause.Occur.MUST_NOT);
> mbq.add(alld, BooleanClause.Occur.MUST);
>
> -Yonik
>
>
> On 12/20/05, javier muguruza <jmuguruza@gmail.com> wrote:
> > Hi,
> >
> > If I run a query like this:
> > -(-body:angel) -(-body:darpa)
> > I get 0 hits. As I did not find any thread about that case, I though
> > ANDing with a MatchAllDocsQuery would return my desired set (all docs
> > excepting the ones with angel or darpa).
> >
> > So more I do the following:
> > BooleanQuery mbq = new BooleanQuery();
> > BooleanQuery mydocs = -body:darpa query;
> > MatchAllDocsQuery alldocs = new MatchAllDocsQuery();
> > mbq.add(mydocs , BooleanClause.Occur.MUST_NOT);
> > mbq.add(alld, BooleanClause.Occur.MUST);
> >
> > and I still get 0 hits, if I only add the alldocs query I get some
> > hits, does anyone see something wrong with my approach?
> >
> > javier
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message