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 Steven White <sw...@gmail.com> on 2016/05/23 12:52:58 UTC

How to use "fq"

Hi everyone,

I'm trying to figure out what's the best way for me to use "fq" when the
list of items is large (up to 200, but I have few cases with up to 1000).

My current usage is like so: &fq=category:(1 OR 2 OR 3 OR 4 ... 200)

When I tested with up to 1000, I hit the "too many boolean clauses", so my
fix was to increase the value of maxBooleanClauses.  However, reading [1]
warns that increasing the value of maxBooleanClauses has negative impact.
The link offers an alternative usage like so:
fq=category:1&fq=category:2...  But I cannot use it because I need my "fq"
to be treated as OR (my default is set to AND).

I'm trying to understand what's the best way for me to coded this so I
don't get a performance or memory hit.

Thanks

Steve

[1]
http://solr.pl/en/2011/12/19/do-i-have-to-look-for-maxbooleanclauses-when-using-filters/

Re: How to use "fq"

Posted by Erick Erickson <er...@gmail.com>.
Steven:

I'm not sure you can, the terms query parser is built to
OR things together.

You might be able to use some of the nested query stuff.
Or, assuming you have an _additional_ fq clause
you want to use just use it as:
fq={!terms f=category}1,2,3,4,...N&fq=whaterver

Then you're taking advantage of the default
behavior of multiple "fq" clauses.

And I'd do one other thing, I'd add "cache=false" (at least I'm
pretty sure this works):
fq={!terms f=category cache=false}1,2,3,4,...N
on the assumption that it's highly unlikely that you'll send in
another fq clause _exactly_ like the one you're creating.

Best,
Erick

On Mon, May 23, 2016 at 9:41 AM, Steven White <sw...@gmail.com> wrote:
> Thank you Erik and Scott.  {!terms} did the job!!  I tested like so:
> fq={!terms f=category}1,2,3,4,...N
>
> I read that {!terms} treats the terms in the list as OR, if I have a need
> to force AND on my terms, how do I do that?
>
> Steve
>
>
> On Mon, May 23, 2016 at 9:39 AM, Scott Chu <sc...@udngroup.com> wrote:
>
>>
>> Yonik has a very well article about term qp:
>>
>> Solr Terms Query for matching many terms - Solr 'n Stuff
>> http://yonik.com/solr-terms-query/
>>
>>
>> Scott Chu,scott.chu@udngroup.com
>> 2016/5/23 (週一)
>> ----- Original Message -----
>> From: Erik Hatcher
>> To: solr-user
>> CC:
>> Date: 2016/5/23 (週一) 21:14
>> Subject: Re: How to use "fq"
>>
>>
>> Try the {!terms} query parser. That should make it work well for you. Let
>> us know how it does.
>>
>>    Erik
>>
>> > On May 23, 2016, at 08:52, Steven White <sw...@gmail.com> wrote:
>> >
>> > Hi everyone,
>> >
>> > I'm trying to figure out what's the best way for me to use "fq" when the
>>
>> > list of items is large (up to 200, but I have few cases with up to 1000).
>> >
>> > My current usage is like so: &fq=category:(1 OR 2 OR 3 OR 4 ... 200)
>> >
>> > When I tested with up to 1000, I hit the "too many boolean clauses", so
>> my
>> > fix was to increase the value of maxBooleanClauses. However, reading [1]
>> > warns that increasing the value of maxBooleanClauses has negative impact.
>> > The link offers an alternative usage like so:
>> > fq=category:1&fq=category:2... But I cannot use it because I need my "fq"
>> > to be treated as OR (my default is set to AND).
>> >
>> > I'm trying to understand what's the best way for me to coded this so I
>> > don't get a performance or memory hit.
>> >
>> > Thanks
>> >
>> > Steve
>> >
>> > [1]
>> >
>> http://solr.pl/en/2011/12/19/do-i-have-to-look-for-maxbooleanclauses-when-using-filters/
>>
>>
>> -----
>> ???????????
>> ??? AVG ?? - www.avg.com
>> ??: 2015.0.6201 / ???: 4568/12281 - ????: 05/23/16
>>

Re: How to use "fq"

Posted by Yonik Seeley <ys...@gmail.com>.
On Mon, May 23, 2016 at 12:41 PM, Steven White <sw...@gmail.com> wrote:
> Thank you Erik and Scott.  {!terms} did the job!!  I tested like so:
> fq={!terms f=category}1,2,3,4,...N
>
> I read that {!terms} treats the terms in the list as OR, if I have a need
> to force AND on my terms, how do I do that?

While ORing a thousand terms seems to be common (categories, unique ids, etc)
I haven't really seen that use-case with AND.  I'm curious what your
use case is.

-Yonik

Re: How to use "fq"

Posted by Steven White <sw...@gmail.com>.
Thank you Erik and Scott.  {!terms} did the job!!  I tested like so:
fq={!terms f=category}1,2,3,4,...N

I read that {!terms} treats the terms in the list as OR, if I have a need
to force AND on my terms, how do I do that?

Steve


On Mon, May 23, 2016 at 9:39 AM, Scott Chu <sc...@udngroup.com> wrote:

>
> Yonik has a very well article about term qp:
>
> Solr Terms Query for matching many terms - Solr 'n Stuff
> http://yonik.com/solr-terms-query/
>
>
> Scott Chu,scott.chu@udngroup.com
> 2016/5/23 (週一)
> ----- Original Message -----
> From: Erik Hatcher
> To: solr-user
> CC:
> Date: 2016/5/23 (週一) 21:14
> Subject: Re: How to use "fq"
>
>
> Try the {!terms} query parser. That should make it work well for you. Let
> us know how it does.
>
>    Erik
>
> > On May 23, 2016, at 08:52, Steven White <sw...@gmail.com> wrote:
> >
> > Hi everyone,
> >
> > I'm trying to figure out what's the best way for me to use "fq" when the
>
> > list of items is large (up to 200, but I have few cases with up to 1000).
> >
> > My current usage is like so: &fq=category:(1 OR 2 OR 3 OR 4 ... 200)
> >
> > When I tested with up to 1000, I hit the "too many boolean clauses", so
> my
> > fix was to increase the value of maxBooleanClauses. However, reading [1]
> > warns that increasing the value of maxBooleanClauses has negative impact.
> > The link offers an alternative usage like so:
> > fq=category:1&fq=category:2... But I cannot use it because I need my "fq"
> > to be treated as OR (my default is set to AND).
> >
> > I'm trying to understand what's the best way for me to coded this so I
> > don't get a performance or memory hit.
> >
> > Thanks
> >
> > Steve
> >
> > [1]
> >
> http://solr.pl/en/2011/12/19/do-i-have-to-look-for-maxbooleanclauses-when-using-filters/
>
>
> -----
> ???????????
> ??? AVG ?? - www.avg.com
> ??: 2015.0.6201 / ???: 4568/12281 - ????: 05/23/16
>

Re: How to use "fq"

Posted by Scott Chu <sc...@udngroup.com>.
Yonik has a very well article about term qp:

Solr Terms Query for matching many terms - Solr 'n Stuff
http://yonik.com/solr-terms-query/


Scott Chu,scott.chu@udngroup.com
2016/5/23 (週一)
----- Original Message ----- 
From: Erik Hatcher 
To: solr-user 
CC: 
Date: 2016/5/23 (週一) 21:14
Subject: Re: How to use "fq"


Try the {!terms} query parser. That should make it work well for you. Let us know how it does. 

   Erik 

> On May 23, 2016, at 08:52, Steven White <sw...@gmail.com> wrote: 
> 
> Hi everyone, 
> 
> I'm trying to figure out what's the best way for me to use "fq" when the 

> list of items is large (up to 200, but I have few cases with up to 1000). 
> 
> My current usage is like so: &fq=category:(1 OR 2 OR 3 OR 4 ... 200) 
> 
> When I tested with up to 1000, I hit the "too many boolean clauses", so my 
> fix was to increase the value of maxBooleanClauses. However, reading [1] 
> warns that increasing the value of maxBooleanClauses has negative impact. 
> The link offers an alternative usage like so: 
> fq=category:1&fq=category:2... But I cannot use it because I need my "fq" 
> to be treated as OR (my default is set to AND). 
> 
> I'm trying to understand what's the best way for me to coded this so I 
> don't get a performance or memory hit. 
> 
> Thanks 
> 
> Steve 
> 
> [1] 
> http://solr.pl/en/2011/12/19/do-i-have-to-look-for-maxbooleanclauses-when-using-filters/ 


----- 
??????????? 
??? AVG ?? - www.avg.com 
??: 2015.0.6201 / ???: 4568/12281 - ????: 05/23/16 

Re: How to use "fq"

Posted by Erik Hatcher <er...@gmail.com>.
Try the {!terms} query parser.  That should make it work well for you.  Let us know how it does.  

   Erik

> On May 23, 2016, at 08:52, Steven White <sw...@gmail.com> wrote:
> 
> Hi everyone,
> 
> I'm trying to figure out what's the best way for me to use "fq" when the
> list of items is large (up to 200, but I have few cases with up to 1000).
> 
> My current usage is like so: &fq=category:(1 OR 2 OR 3 OR 4 ... 200)
> 
> When I tested with up to 1000, I hit the "too many boolean clauses", so my
> fix was to increase the value of maxBooleanClauses.  However, reading [1]
> warns that increasing the value of maxBooleanClauses has negative impact.
> The link offers an alternative usage like so:
> fq=category:1&fq=category:2...  But I cannot use it because I need my "fq"
> to be treated as OR (my default is set to AND).
> 
> I'm trying to understand what's the best way for me to coded this so I
> don't get a performance or memory hit.
> 
> Thanks
> 
> Steve
> 
> [1]
> http://solr.pl/en/2011/12/19/do-i-have-to-look-for-maxbooleanclauses-when-using-filters/