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 abhi Abhishek <ab...@gmail.com> on 2017/06/13 07:15:42 UTC

Odd Boolean Query behavior in SOLR 3.6

Hi Everyone,

                I have hit a weird behavior of Boolean Query, when I am
running the query with below param’s  it’s not behaving as expected. can
you please help me understand the behavior here?



q=*:*&fq=((-documentTypeId:3)+AND+companyId:29096)&version=2.2&start=0&rows=10&indent=on&debugQuery=true

 èReturns 0 matches

filter_queries: ((-documentTypeId:3) AND companyId:29096)

parsed_filter_queries: +(-documentTypeId:3) +companyId:29096



q=*:*&fq=(-documentTypeId:3+AND+companyId:29096)&version=2.2&start=0&rows=10&indent=on&debugQuery=true

è returns 1600 matches

filter_queries:(-documentTypeId:3 AND companyId:29096)

parsed_filter_queries:-documentTypeId:3 +companyId:29096



Can you please help me understand what am I missing here?


Thanks in Advance.


Thanks & Best Regards,

Abhishek

Re: Odd Boolean Query behavior in SOLR 3.6

Posted by Erik Hatcher <er...@gmail.com>.
Yes, fq’s make up constraints in conjunction with q.  The issue here though is _clauses_.    A single negative clause matches nothing.  There is syntactic sugar at the Solr level to allow for q and fq’s to have a top-level single negative clause, like q=-type:pdf to return all non-pdf docs.  That’s a shortcut convenience to saying q=*:* -type:pdf.  Once inside nested clauses, have to be explicit.   Gotta match something to exclude stuff.

	Erik


> On Jun 13, 2017, at 10:09 AM, abhi Abhishek <ab...@gmail.com> wrote:
> 
> Thanks Erik, This helped and the query is running and gives results as
> expected.
> 
> Thanks for the insight, my understanding here was that fq parameter works
> on the result set of q parameter which is *:* here. shouldn't that be the
> case here?
> 
> Thanks,
> Abhishek
> 
> 
> 
> On Tue, Jun 13, 2017 at 6:02 PM, Erik Hatcher <er...@gmail.com>
> wrote:
> 
>> Inner purely negative queries match nothing.  A query is about matching,
>> and skipping over things that don’t match.  The fix is when using
>> (-something) to do (*:* -something) to match everything and skip the
>> negative clause items.
>> 
>> In your example, try fq=((*:* -documentTypeId:3) AND companyId:29096)
>> 
>>        Erik
>> 
>>> On Jun 13, 2017, at 3:15 AM, abhi Abhishek <ab...@gmail.com> wrote:
>>> 
>>> Hi Everyone,
>>> 
>>>               I have hit a weird behavior of Boolean Query, when I am
>>> running the query with below param’s  it’s not behaving as expected. can
>>> you please help me understand the behavior here?
>>> 
>>> 
>>> 
>>> q=*:*&fq=((-documentTypeId:3)+AND+companyId:29096)&version=
>> 2.2&start=0&rows=10&indent=on&debugQuery=true
>>> 
>>> èReturns 0 matches
>>> 
>>> filter_queries: ((-documentTypeId:3) AND companyId:29096)
>>> 
>>> parsed_filter_queries: +(-documentTypeId:3) +companyId:29096
>>> 
>>> 
>>> 
>>> q=*:*&fq=(-documentTypeId:3+AND+companyId:29096)&version=
>> 2.2&start=0&rows=10&indent=on&debugQuery=true
>>> 
>>> è returns 1600 matches
>>> 
>>> filter_queries:(-documentTypeId:3 AND companyId:29096)
>>> 
>>> parsed_filter_queries:-documentTypeId:3 +companyId:29096
>>> 
>>> 
>>> 
>>> Can you please help me understand what am I missing here?
>>> 
>>> 
>>> Thanks in Advance.
>>> 
>>> 
>>> Thanks & Best Regards,
>>> 
>>> Abhishek
>> 
>> 
>> ---------------------------------------------------------------------
>> 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: Odd Boolean Query behavior in SOLR 3.6

Posted by abhi Abhishek <ab...@gmail.com>.
Thanks Erik, This helped and the query is running and gives results as
expected.

Thanks for the insight, my understanding here was that fq parameter works
on the result set of q parameter which is *:* here. shouldn't that be the
case here?

Thanks,
Abhishek



On Tue, Jun 13, 2017 at 6:02 PM, Erik Hatcher <er...@gmail.com>
wrote:

> Inner purely negative queries match nothing.  A query is about matching,
> and skipping over things that don’t match.  The fix is when using
> (-something) to do (*:* -something) to match everything and skip the
> negative clause items.
>
> In your example, try fq=((*:* -documentTypeId:3) AND companyId:29096)
>
>         Erik
>
> > On Jun 13, 2017, at 3:15 AM, abhi Abhishek <ab...@gmail.com> wrote:
> >
> > Hi Everyone,
> >
> >                I have hit a weird behavior of Boolean Query, when I am
> > running the query with below param’s  it’s not behaving as expected. can
> > you please help me understand the behavior here?
> >
> >
> >
> > q=*:*&fq=((-documentTypeId:3)+AND+companyId:29096)&version=
> 2.2&start=0&rows=10&indent=on&debugQuery=true
> >
> > èReturns 0 matches
> >
> > filter_queries: ((-documentTypeId:3) AND companyId:29096)
> >
> > parsed_filter_queries: +(-documentTypeId:3) +companyId:29096
> >
> >
> >
> > q=*:*&fq=(-documentTypeId:3+AND+companyId:29096)&version=
> 2.2&start=0&rows=10&indent=on&debugQuery=true
> >
> > è returns 1600 matches
> >
> > filter_queries:(-documentTypeId:3 AND companyId:29096)
> >
> > parsed_filter_queries:-documentTypeId:3 +companyId:29096
> >
> >
> >
> > Can you please help me understand what am I missing here?
> >
> >
> > Thanks in Advance.
> >
> >
> > Thanks & Best Regards,
> >
> > Abhishek
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

Re: Odd Boolean Query behavior in SOLR 3.6

Posted by Erik Hatcher <er...@gmail.com>.
Inner purely negative queries match nothing.  A query is about matching, and skipping over things that don’t match.  The fix is when using (-something) to do (*:* -something) to match everything and skip the negative clause items.

In your example, try fq=((*:* -documentTypeId:3) AND companyId:29096)

	Erik

> On Jun 13, 2017, at 3:15 AM, abhi Abhishek <ab...@gmail.com> wrote:
> 
> Hi Everyone,
> 
>                I have hit a weird behavior of Boolean Query, when I am
> running the query with below param’s  it’s not behaving as expected. can
> you please help me understand the behavior here?
> 
> 
> 
> q=*:*&fq=((-documentTypeId:3)+AND+companyId:29096)&version=2.2&start=0&rows=10&indent=on&debugQuery=true
> 
> èReturns 0 matches
> 
> filter_queries: ((-documentTypeId:3) AND companyId:29096)
> 
> parsed_filter_queries: +(-documentTypeId:3) +companyId:29096
> 
> 
> 
> q=*:*&fq=(-documentTypeId:3+AND+companyId:29096)&version=2.2&start=0&rows=10&indent=on&debugQuery=true
> 
> è returns 1600 matches
> 
> filter_queries:(-documentTypeId:3 AND companyId:29096)
> 
> parsed_filter_queries:-documentTypeId:3 +companyId:29096
> 
> 
> 
> Can you please help me understand what am I missing here?
> 
> 
> Thanks in Advance.
> 
> 
> Thanks & Best Regards,
> 
> Abhishek


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: Odd Boolean Query behavior in SOLR 3.6

Posted by Erik Hatcher <er...@gmail.com>.
Inner purely negative queries match nothing.  A query is about matching, and skipping over things that don’t match.  The fix is when using (-something) to do (*:* -something) to match everything and skip the negative clause items.

In your example, try fq=((*:* -documentTypeId:3) AND companyId:29096)

	Erik

> On Jun 13, 2017, at 3:15 AM, abhi Abhishek <ab...@gmail.com> wrote:
> 
> Hi Everyone,
> 
>                I have hit a weird behavior of Boolean Query, when I am
> running the query with below param’s  it’s not behaving as expected. can
> you please help me understand the behavior here?
> 
> 
> 
> q=*:*&fq=((-documentTypeId:3)+AND+companyId:29096)&version=2.2&start=0&rows=10&indent=on&debugQuery=true
> 
> èReturns 0 matches
> 
> filter_queries: ((-documentTypeId:3) AND companyId:29096)
> 
> parsed_filter_queries: +(-documentTypeId:3) +companyId:29096
> 
> 
> 
> q=*:*&fq=(-documentTypeId:3+AND+companyId:29096)&version=2.2&start=0&rows=10&indent=on&debugQuery=true
> 
> è returns 1600 matches
> 
> filter_queries:(-documentTypeId:3 AND companyId:29096)
> 
> parsed_filter_queries:-documentTypeId:3 +companyId:29096
> 
> 
> 
> Can you please help me understand what am I missing here?
> 
> 
> Thanks in Advance.
> 
> 
> Thanks & Best Regards,
> 
> Abhishek