lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Satuluri, Venu_Madhav" <Venu.Madhav.Satul...@deshaw.com>
Subject RE: Using NOT queries inside parentheses
Date Tue, 07 Mar 2006 16:29:57 GMT

>   Query at = new TermQuery(new Term("alwaysTrueField","true));
>   Query user = queryParser.parse(userInput);
>   if (user instanceof BooleanQuery) {
>      BooleanQuery bq = (BooleanQuery)user;
>      if (! usableBooleanQuery(bq)) {
>         bq.add(at, true, false); /* add 'always true' clause directly
*/
>         return bq;
>      }
>   }
>   /* if we made it here, wrape both clauses.
>  BooleanQuery q = new BooleanQuery();
>   q.add(at, true, false);
>   q.add(user, true, false);
>   return q;

Many thanks, Chris, its working for me perfectly.

> If you want this to work, the most elegant way I've found is to
override 
> the getBooleanQuery(Vector) method in QueryParser and insert a 
> MatchAllDocsQuery into the boolean query if every clause is
prohibited.
> 
> Daniel

I tried this, but it looks like the overridden method
getBooleanQuery(vector) does not get called. I am using 1.4.3.

Thanks,
Venu





---------------------------------------------------------------------
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