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 Tanner Postert <ta...@gmail.com> on 2011/03/03 18:16:11 UTC

FilterQuery OR statement

Trying to figure out how I can run something similar to this for the fq
parameter

Field1 in ( 1, 2, 3 4 )
AND
Field2 in ( 4, 5, 6, 7 )

I found some examples on the net that looked like this: &fq=+field1:(1 2 3
4) +field2(4 5 6 7) but that yields no results.

Re: FilterQuery OR statement

Posted by Jonathan Rochkind <ro...@jhu.edu>.
You might also consider splitting your two seperate "AND" clauses into 
two seperate fq's:

&fq=field1:(1 OR 2 OR 3 OR 4)
&fq=field2:(4 OR 5 OR 6 OR 7)

That will cache the two seperate clauses seperately in the field cache, 
which is probably preferable in general, without knowing more about your 
use characteristics.

ALSO, instead of either supplying the "OR" explicitly as above, OR 
changing the default operator in schema.xml for everything, I believe it 
would work to supply it as a local param:

&fq={q.op=OR}field1:(1 2 3 4)

If you want to do that.

AND, your question, can you search without a 'q'?  No, but you can 
search with a 'q' that selects all documents, to be limited by the fq's.

q=[* TO *]

On 3/3/2011 1:14 PM, Tanner Postert wrote:
> That worked, thought I tried it before, not sure why it didn't before.
>
> Also, is there a way to query without a q parameter?
>
> I'm just trying to pull back all of the field results where field1:(1 OR 2
> OR 3) etc. so I figured I'd use the FQ param for caching purposes because
> those queries will likely be run a lot, but if I leave the Q parameter off i
> get a null pointer error.
>
> On Thu, Mar 3, 2011 at 11:05 AM, Ahmet Arslan<io...@yahoo.com>  wrote:
>
>>> Trying to figure out how I can run
>>> something similar to this for the fq
>>> parameter
>>>
>>> Field1 in ( 1, 2, 3 4 )
>>> AND
>>> Field2 in ( 4, 5, 6, 7 )
>>>
>>> I found some examples on the net that looked like this:
>>> &fq=+field1:(1 2 3
>>> 4) +field2(4 5 6 7) but that yields no results.
>> May be your default operator is set to AND in schema.xml?
>> If yes, try using +field2(4 OR 5 OR 6 OR 7)
>>
>>
>>
>>

Re: FilterQuery OR statement

Posted by Tanner Postert <ta...@gmail.com>.
That worked, thought I tried it before, not sure why it didn't before.

Also, is there a way to query without a q parameter?

I'm just trying to pull back all of the field results where field1:(1 OR 2
OR 3) etc. so I figured I'd use the FQ param for caching purposes because
those queries will likely be run a lot, but if I leave the Q parameter off i
get a null pointer error.

On Thu, Mar 3, 2011 at 11:05 AM, Ahmet Arslan <io...@yahoo.com> wrote:

> > Trying to figure out how I can run
> > something similar to this for the fq
> > parameter
> >
> > Field1 in ( 1, 2, 3 4 )
> > AND
> > Field2 in ( 4, 5, 6, 7 )
> >
> > I found some examples on the net that looked like this:
> > &fq=+field1:(1 2 3
> > 4) +field2(4 5 6 7) but that yields no results.
>
> May be your default operator is set to AND in schema.xml?
> If yes, try using +field2(4 OR 5 OR 6 OR 7)
>
>
>
>

Re: FilterQuery OR statement

Posted by Ahmet Arslan <io...@yahoo.com>.
--- On Thu, 3/3/11, Ahmet Arslan <io...@yahoo.com> wrote:

> From: Ahmet Arslan <io...@yahoo.com>
> Subject: Re: FilterQuery OR statement
> To: solr-user@lucene.apache.org
> Date: Thursday, March 3, 2011, 8:05 PM
> > Trying to figure out how I can
> run
> > something similar to this for the fq
> > parameter
> > 
> > Field1 in ( 1, 2, 3 4 )
> > AND
> > Field2 in ( 4, 5, 6, 7 )
> > 
> > I found some examples on the net that looked like
> this:
> > &fq=+field1:(1 2 3
> > 4) +field2(4 5 6 7) but that yields no results.
> 
> May be your default operator is set to AND in schema.xml?
> If yes, try using +field2(4 OR 5 OR 6 OR 7) 

Actually you can use local params for that.
http://wiki.apache.org/solr/LocalParams

&fq={!q.op=OR df=field1}1 2 3 4&fq={!q.op=OR df=field2}4 5 6 7


      

Re: FilterQuery OR statement

Posted by Ahmet Arslan <io...@yahoo.com>.
> Trying to figure out how I can run
> something similar to this for the fq
> parameter
> 
> Field1 in ( 1, 2, 3 4 )
> AND
> Field2 in ( 4, 5, 6, 7 )
> 
> I found some examples on the net that looked like this:
> &fq=+field1:(1 2 3
> 4) +field2(4 5 6 7) but that yields no results.

May be your default operator is set to AND in schema.xml?
If yes, try using +field2(4 OR 5 OR 6 OR 7)