You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Alexander Golubowitsch <al...@antikoerper-online.de> on 2012/03/15 16:23:13 UTC

Filter Queries: Intersection

Hi all,

  I'm facing problems regarding multiple Filter Queries in SOLR 1.4.1 - 
I hope some one will be able to help.

Example 1 - works fine: {!tag=myfieldtag}(-(myfield:*))
Example 2 - works fine: {!tag=myfieldtag}((myfield:"Bio" | myfield:"Alexa"))

Please note that in Example 2, result sets of individual filter queries 
do not intersect; 'OR' just works as expected.

Example 3 - no results: {!tag=myfieldtag}((myfield:"Bio" | 
myfield:"Alexa") | -(myfield:*))

What I am trying to generate is results having either no value for 
myfield, or any of {"Alexa", "Bio"}.

How would I acomplish that?
I have tried all combinations/positions of brackets, +/- etc., without 
success.

Thanks a lot for any advice!

Kind regards,
  Alex

Re: Filter Queries: Intersection

Posted by Alexander Golubowitsch <al...@antikoerper-online.de>.
http://www.lucidimagination.com/blog/2011/12/28/why-not-and-or-and-not/

->  That's an excellent read - thanks a lot for the heads-up!

Kind regards,
  Alex

On 16.03.2012 14:08, Erick Erickson wrote:
> Your problem is that you're saying with the -myField:* "Remove from
> the result set all documents with any value in myField", which is not
> what you want. Lucene query language is not strictly boolean logic,
> here's an excellent writeup:
>
> http://www.lucidimagination.com/blog/2011/12/28/why-not-and-or-and-not/
>
> you want something like
> (myfield:bob myfield:alice) (*:* -myfield:*)
>
> Best
> Erick
>
> On Thu, Mar 15, 2012 at 10:23 AM, Alexander Golubowitsch
> <al...@antikoerper-online.de>  wrote:
>> Hi all,
>>
>>   I'm facing problems regarding multiple Filter Queries in SOLR 1.4.1 - I
>> hope some one will be able to help.
>>
>> Example 1 - works fine: {!tag=myfieldtag}(-(myfield:*))
>> Example 2 - works fine: {!tag=myfieldtag}((myfield:"Bio" | myfield:"Alexa"))
>>
>> Please note that in Example 2, result sets of individual filter queries do
>> not intersect; 'OR' just works as expected.
>>
>> Example 3 - no results: {!tag=myfieldtag}((myfield:"Bio" | myfield:"Alexa")
>> | -(myfield:*))
>>
>> What I am trying to generate is results having either no value for myfield,
>> or any of {"Alexa", "Bio"}.
>>
>> How would I acomplish that?
>> I have tried all combinations/positions of brackets, +/- etc., without
>> success.
>>
>> Thanks a lot for any advice!
>>
>> Kind regards,
>>   Alex

Re: Filter Queries: Intersection

Posted by Erick Erickson <er...@gmail.com>.
Your problem is that you're saying with the -myField:* "Remove from
the result set all documents with any value in myField", which is not
what you want. Lucene query language is not strictly boolean logic,
here's an excellent writeup:

http://www.lucidimagination.com/blog/2011/12/28/why-not-and-or-and-not/

you want something like
(myfield:bob myfield:alice) (*:* -myfield:*)

Best
Erick

On Thu, Mar 15, 2012 at 10:23 AM, Alexander Golubowitsch
<al...@antikoerper-online.de> wrote:
> Hi all,
>
>  I'm facing problems regarding multiple Filter Queries in SOLR 1.4.1 - I
> hope some one will be able to help.
>
> Example 1 - works fine: {!tag=myfieldtag}(-(myfield:*))
> Example 2 - works fine: {!tag=myfieldtag}((myfield:"Bio" | myfield:"Alexa"))
>
> Please note that in Example 2, result sets of individual filter queries do
> not intersect; 'OR' just works as expected.
>
> Example 3 - no results: {!tag=myfieldtag}((myfield:"Bio" | myfield:"Alexa")
> | -(myfield:*))
>
> What I am trying to generate is results having either no value for myfield,
> or any of {"Alexa", "Bio"}.
>
> How would I acomplish that?
> I have tried all combinations/positions of brackets, +/- etc., without
> success.
>
> Thanks a lot for any advice!
>
> Kind regards,
>  Alex