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 VJ <ja...@gmail.com> on 2017/04/24 10:59:18 UTC

Mixing AND OR conditions with query parameters

Hi All,

I am facing issues with OR/AND conditions with query parameters:

fq=cioname:"XYZ" & (fq=attr1:trueORattr2:true)

The queries are not returning expected results.

I have tried various permutation and combinations but couldn't get it
working. Any pointers on this?



Regards,
VJ

Re: Mixing AND OR conditions with query parameters

Posted by VJ <ja...@gmail.com>.
Thanks MIchael and Erick.

With your valuable comments I finally managed to get the expected result
out of the query.

Regards,
VJ



On Mon, Apr 24, 2017 at 8:17 PM, Erick Erickson <er...@gmail.com>
wrote:

> Michael's comments are spot on, and the deeper thing you should be
> aware of is that Solr query parsing does not implement strict boolean
> logic, see Chris Hostetter's excellent blog here:
> https://lucidworks.com/2011/12/28/why-not-and-or-and-not/
>
> As Michael suggests, parenthesizing carefully can make the parsing
> behave like boolean logic.
>
> Best,
> Erick
>
> On Mon, Apr 24, 2017 at 4:05 AM, Michael Kuhlmann <ku...@solr.info> wrote:
> > Make sure to have a whitespace are the OR operator.
> >
> > The parenthesises should be around the OR query, not including the "fq:"
> > -- this should be outside the parenthesises (which are not necessary at
> > all).
> >
> > What exactly are you expecting?
> >
> > -Michael
> >
> > Am 24.04.2017 um 12:59 schrieb VJ:
> >> Hi All,
> >>
> >> I am facing issues with OR/AND conditions with query parameters:
> >>
> >> fq=cioname:"XYZ" & (fq=attr1:trueORattr2:true)
> >>
> >> The queries are not returning expected results.
> >>
> >> I have tried various permutation and combinations but couldn't get it
> >> working. Any pointers on this?
> >>
> >>
> >>
> >> Regards,
> >> VJ
> >>
> >
>

Re: Mixing AND OR conditions with query parameters

Posted by Erick Erickson <er...@gmail.com>.
Michael's comments are spot on, and the deeper thing you should be
aware of is that Solr query parsing does not implement strict boolean
logic, see Chris Hostetter's excellent blog here:
https://lucidworks.com/2011/12/28/why-not-and-or-and-not/

As Michael suggests, parenthesizing carefully can make the parsing
behave like boolean logic.

Best,
Erick

On Mon, Apr 24, 2017 at 4:05 AM, Michael Kuhlmann <ku...@solr.info> wrote:
> Make sure to have a whitespace are the OR operator.
>
> The parenthesises should be around the OR query, not including the "fq:"
> -- this should be outside the parenthesises (which are not necessary at
> all).
>
> What exactly are you expecting?
>
> -Michael
>
> Am 24.04.2017 um 12:59 schrieb VJ:
>> Hi All,
>>
>> I am facing issues with OR/AND conditions with query parameters:
>>
>> fq=cioname:"XYZ" & (fq=attr1:trueORattr2:true)
>>
>> The queries are not returning expected results.
>>
>> I have tried various permutation and combinations but couldn't get it
>> working. Any pointers on this?
>>
>>
>>
>> Regards,
>> VJ
>>
>

Re: Mixing AND OR conditions with query parameters

Posted by Michael Kuhlmann <ku...@solr.info>.
Make sure to have a whitespace are the OR operator.

The parenthesises should be around the OR query, not including the "fq:"
-- this should be outside the parenthesises (which are not necessary at
all).

What exactly are you expecting?

-Michael

Am 24.04.2017 um 12:59 schrieb VJ:
> Hi All,
>
> I am facing issues with OR/AND conditions with query parameters:
>
> fq=cioname:"XYZ" & (fq=attr1:trueORattr2:true)
>
> The queries are not returning expected results.
>
> I have tried various permutation and combinations but couldn't get it
> working. Any pointers on this?
>
>
>
> Regards,
> VJ
>