You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Jason <je...@hardlight.com.au> on 2007/01/10 16:32:25 UTC
how can I filter my search to not include items containing a particular
field and value?
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: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: how can I filter my search to not include items containing a
particular field and value?
Posted by Jason <je...@hardlight.com.au>.
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 <je...@hardlight.com.au> 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: 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
Re: how can I filter my search to not include items containing a particular field and value?
Posted by Erick Erickson <er...@gmail.com>.
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 <er...@gmail.com> 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 <je...@hardlight.com.au> 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: java-user-unsubscribe@lucene.apache.org
> > For additional commands, e-mail: java-user-help@lucene.apache.org
> >
> >
>
Re: how can I filter my search to not include items containing a particular field and value?
Posted by Erick Erickson <er...@gmail.com>.
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 <je...@hardlight.com.au> 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: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>