lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Kristensson <mark.kristens...@smartsheet.com>
Subject Re: Not query help.
Date Wed, 24 Nov 2010 01:14:45 GMT
I've had to deal with exactly this same scenario and, from what I know,
there is no equivalent in Lucene to a SQL != kind of query. So, you have to
have some way to select "everything" (whatever that means in your scenario)
and then remove the stuff that you don't want (the NOT portion). For my
application, I have a user permission field that I can use to select
everything that a user has access to and then I can "NOT out" the stuff
specified by the != portion of the query. These, of course, are two queries
that I AND together with a BooleanQuery.

-Mark

On Tue, Nov 23, 2010 at 5:04 PM, Nabib El-Rahman <nabiber@gmail.com> wrote:

> Hi,
>
> What I need is a Not TermQuery. I did not see one in the API, so I did the
> following:
>
> Query query = new BooleanQuery(new BooleanClause(new
> TermQuery(..), BooleanClause.Occur.MUST_NOT)));
>
> This did not produce the correct search result. Does anyone have any idea
> on
> how to accomplish this?
>
> And is here such a thing as NotTermQuery(..) ?
>
> Thanks in advance!
>
> -Nabib
>

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