how can I filter my search to not include items containing a particular field and value?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

how can I filter my search to not include items containing a particular field and value?

Jason Eacott-2
how can I filter my search to not include items containing a particular
field and value?

I want effectively to add -myfieldname:myvalue to the end of  my search
query, but I cant see how to do this via the api.
I have a complex query built up via the api and just want to filter it
based on field name/value pairs.

I'm sure it must be simple - I just cant see how to do it.

thanks.
Jason.

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: how can I filter my search to not include items containing a particular field and value?

Erick Erickson
Would something like the following work for you?

BooleanQuery bq = new BooleanQuery();
bq.add(your built-up query);
bq.add(your not clause, MUSTNOT);


Now you can use your bq as your query to search.


NOTE: there is continual confusion what the - syntax really does, you might
want to search the mail archive for one of several explications if you are
thinking of the NOT operator like a boolean logic operator. It's not, quite.

On 1/10/07, Jason <[hidden email]> wrote:

>
> how can I filter my search to not include items containing a particular
> field and value?
>
> I want effectively to add -myfieldname:myvalue to the end of  my search
> query, but I cant see how to do this via the api.
> I have a complex query built up via the api and just want to filter it
> based on field name/value pairs.
>
> I'm sure it must be simple - I just cant see how to do it.
>
> thanks.
> Jason.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: how can I filter my search to not include items containing a particular field and value?

Erick Erickson
As luck would have it, there's an explanation of the NOT operator in the
thread below posted after your original one.......


*Getting a Better Understanding of Lucene's Search Operators


*
On 1/10/07, Erick Erickson <[hidden email]> wrote:

>
> Would something like the following work for you?
>
> BooleanQuery bq = new BooleanQuery();
> bq.add(your built-up query);
> bq.add(your not clause, MUSTNOT);
>
>
> Now you can use your bq as your query to search.
>
>
> NOTE: there is continual confusion what the - syntax really does, you
> might want to search the mail archive for one of several explications if you
> are thinking of the NOT operator like a boolean logic operator. It's not,
> quite.
>
> On 1/10/07, Jason <[hidden email]> wrote:
> >
> > how can I filter my search to not include items containing a particular
> > field and value?
> >
> > I want effectively to add -myfieldname:myvalue to the end of  my search
> > query, but I cant see how to do this via the api.
> > I have a complex query built up via the api and just want to filter it
> > based on field name/value pairs.
> >
> > I'm sure it must be simple - I just cant see how to do it.
> >
> > thanks.
> > Jason.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]
> > For additional commands, e-mail: [hidden email]
> >
> >
>
Reply | Threaded
Open this post in threaded view
|

Re: how can I filter my search to not include items containing a particular field and value?

Jason Eacott-2
In reply to this post by Erick Erickson
Thanks Erick,
        this is what I ended up doing more or less but I'm not happy with it
really,
                                                 hparser.setDefaultOperator(QueryParser.Operator.AND);
Query hideQuery =hparser.parse("properties@"+hideterm+":"+hidevalue);

cquery.add(hideQuery, BooleanClause.Occur.MUST_NOT);

what I was really looking for was a way to code the fields I wanted
hidden without such a loose interface. I was expecting something like a
fieldQuery object but couldn't find anything appropriate.

Thank you for your help.

Erick Erickson wrote:

> Would something like the following work for you?
>
> BooleanQuery bq = new BooleanQuery();
> bq.add(your built-up query);
> bq.add(your not clause, MUSTNOT);
>
>
> Now you can use your bq as your query to search.
>
>
> NOTE: there is continual confusion what the - syntax really does, you might
> want to search the mail archive for one of several explications if you are
> thinking of the NOT operator like a boolean logic operator. It's not,
> quite.
>
> On 1/10/07, Jason <[hidden email]> wrote:
>>
>> how can I filter my search to not include items containing a particular
>> field and value?
>>
>> I want effectively to add -myfieldname:myvalue to the end of  my search
>> query, but I cant see how to do this via the api.
>> I have a complex query built up via the api and just want to filter it
>> based on field name/value pairs.
>>
>> I'm sure it must be simple - I just cant see how to do it.
>>
>> thanks.
>> Jason.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]