lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Amrit Jassal <ajas...@gmail.com>
Subject Re: Custom filters and booleanquery (MUST_NOT)
Date Fri, 10 Feb 2006 06:54:33 GMT
Chris

Thanks. Appreciate your comment about using ConstantScoreQuery as well.

Amrit

On 2/9/06, Chris Hostetter <hossman_lucene@fucit.org> wrote:
>
>
> : I am experimenting with using a custom filter with QueryParser and ran
> into
> : some unanticipated issues with using NOT terms. I narrowed down the
> issue
>
>     ...
>
> :             bquery = new BooleanQuery();
> :             bquery.add(new BooleanClause(fq,
> BooleanClause.Occur.MUST_NOT));
> :             hits = this.searcher.search(bquery);
> :             assertTrue(hits.length() == 1);       // <<<<<<<<<
returns
> 0, expecting doc #2 (t2) to return...
>
> ...this isn't really a Filter issue at all, you're trying to execute a
> query that only contains prohibited (ie: MUST_NOT) clauses.  Thus you are
> not positively selecting anything -- this is one of hte main use for
> MatchAllDocsQuery, try...
>
>
>           bquery = new BooleanQuery();
>           bquery.add(new BooleanClause(fq, BooleanClause.Occur.MUST_NOT));
>           bquery.add(new BooleanClause(new MatchAllDocsQuery(),
>                      BooleanClause.Occur.MUST));
>           hits = this.searcher.search(bquery);
>           assertTrue(hits.length() == 1);
>
> ...incidently, if you are constructing a FilteredQuery arround a
> MatchAllDocsQuery, you might as well use a ConstantScoreQuery instead.
>
>
> -Hoss
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message