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 "Doddamani, Prakash" <pr...@corp.aol.com> on 2010/05/18 16:31:53 UTC

how to achieve filters

Hi All

I am using "dismax" query to fetch docs from solr where I have set some
boost to the each fields,

 

If I search for query "Rock" I get following docs with some boost value
which I have specified,

 

<doc>
  <float name="score">19.494072</float>
  <int name="bitrate">120</int>
  <str name="content">mp3</str>
  <str name="genre">Rock</str>
  <str name="id">1</str>
  <str name="name">st name 1</str>
</doc>
<doc>
  <float name="score">19.494052</float>
  <int name="bitrate">248</int>
  <str name="content">aac+</str>
  <str name="genre">Rock</str>
  <str name="id">2</str>
  <str name="name">st name 2</str>
</doc>
<doc>
  <float name="score">19.494042</float>
  <int name="bitrate">127</int>
  <str name="content">aac+</str>
  <str name="genre">Rock</str>
  <str name="id">3</str>
  <str name="name">st name 3</str>
</doc>
<doc>
  <float name="score">19.494032</float>
  <int name="bitrate">256</int>
  <str name="content">mp3</str>
  <str name="genre">Rock</str>
  <str name="id">4</str>
  <str name="name">st name 5</str>
</doc>
 

I am looking for something below What is the best way to achieve them ?

1. Query=rock where content= mp3 where it should return only first and
last docs where content=mp3

2. Query=rock where bitrate<128 where it should return only first and
third docs where bitrate<128

 

 

Thanks in advance

Prakash


RE: how to achieve filters

Posted by "Doddamani, Prakash" <pr...@corp.aol.com>.
Thanks Ahmet,

Let me try these options

Regards
Prakash  

-----Original Message-----
From: Ahmet Arslan [mailto:iorixxx@yahoo.com] 
Sent: Tuesday, May 18, 2010 9:06 PM
To: solr-user@lucene.apache.org
Subject: RE: how to achieve filters

> Yep content is string, and bitrate is int.

bitrate should be trie based tint, not int, for range queries work
correctly.

> I am digging more now Can we combine both the scenarios.
> 
> q=rock&fq={!field f=content}mp3
> q=rock&fq:bitrate:[* TO 128]
> 
> Say if I want only mp3 from 0 to 128

You can append filter queries (fq) as many as you want. 

&q=rock&fq={!field f=content}mp3&fq=bitrate:[* TO 128]




      

RE: how to achieve filters

Posted by "Doddamani, Prakash" <pr...@corp.aol.com>.
Oops my bad, 

Thanks much 

-----Original Message-----
From: Ahmet Arslan [mailto:iorixxx@yahoo.com] 
Sent: Thursday, May 20, 2010 4:31 PM
To: solr-user@lucene.apache.org
Subject: RE: how to achieve filters


>  
> And the request I am passing is
> /solr/select?indent=on&version=2.2&q=rock&fq={!field%20f=content}mp3&f
> q:bitrate:[*
> TO 127]
> &start=0&rows=10&fl=*%2Cscore&qt=dismax&wt=standard&explainOther=&hl.f
> l
> 
> Still I am seeing documents above bitarate 127

There is a typo instead of fq: there should be fq= 

&fq=bitrate:[* TO 127]


      

RE: how to achieve filters

Posted by Ahmet Arslan <io...@yahoo.com>.
>  
> And the request I am passing is 
> /solr/select?indent=on&version=2.2&q=rock&fq={!field%20f=content}mp3&fq:bitrate:[*
> TO 127]
> &start=0&rows=10&fl=*%2Cscore&qt=dismax&wt=standard&explainOther=&hl.fl
> 
> Still I am seeing documents above bitarate 127 

There is a typo instead of fq: there should be fq= 

&fq=bitrate:[* TO 127]


      

RE: how to achieve filters

Posted by "Doddamani, Prakash" <pr...@corp.aol.com>.
Hey Ahmet

I have added 

<field name="bitrate" type="sint" indexed="true" stored="true" default="0"/>
 
And the request I am passing is 
/solr/select?indent=on&version=2.2&q=rock&fq={!field%20f=content}mp3&fq:bitrate:[* TO 127] &start=0&rows=10&fl=*%2Cscore&qt=dismax&wt=standard&explainOther=&hl.fl

Still I am seeing documents above bitarate 127 

Regards
Prakash

-----Original Message-----
From: Ahmet Arslan [mailto:iorixxx@yahoo.com] 
Sent: Thursday, May 20, 2010 4:09 PM
To: solr-user@lucene.apache.org
Cc: Doddamani, Prakash
Subject: RE: how to achieve filters


> I am getting Error in Solr
> Error loading class 'Solr.TrieField'
> 
> I have added following in Types of schema file
> 
> <fieldType name="tint" class="solr.TrieField"
> omitNorms="true" />
> 
> And in custom fields of schema have added
> 
> <field name="bitrate" type="tint" indexed="true"
> stored="true" />
>     
> I am using solr version 1.3 cant I handle filter(my example
> bitrate) with sint

Sure you can handle, if you are using solr 1.3.0 you need to use sint type.


      

RE: how to achieve filters

Posted by Ahmet Arslan <io...@yahoo.com>.
> I am getting Error in Solr
> Error loading class 'Solr.TrieField'
> 
> I have added following in Types of schema file
> 
> <fieldType name="tint" class="solr.TrieField"
> omitNorms="true" />
> 
> And in custom fields of schema have added
> 
> <field name="bitrate" type="tint" indexed="true"
> stored="true" />
>     
> I am using solr version 1.3 cant I handle filter(my example
> bitrate) with sint    

Sure you can handle, if you are using solr 1.3.0 you need to use sint type.


      

RE: how to achieve filters

Posted by "Doddamani, Prakash" <pr...@corp.aol.com>.
Hi All 

I am getting Error in Solr
Error loading class 'Solr.TrieField'

I have added following in Types of schema file

<fieldType name="tint" class="solr.TrieField" omitNorms="true" />

And in custom fields of schema have added

<field name="bitrate" type="tint" indexed="true" stored="true" />
    
I am using solr version 1.3 cant I handle filter(my example bitrate) with sint    

Thanks
Prakash



Ahmet wrote......

> Yep content is string, and bitrate is int.

bitrate should be trie based tint, not int, for range queries work correctly.

> I am digging more now Can we combine both the scenarios.
> 
> q=rock&fq={!field f=content}mp3
> q=rock&fq:bitrate:[* TO 128]
> 
> Say if I want only mp3 from 0 to 128

You can append filter queries (fq) as many as you want. 

&q=rock&fq={!field f=content}mp3&fq=bitrate:[* TO 128]


 

-----Original Message-----
From: Doddamani, Prakash [mailto:prakash.doddamani@corp.aol.com] 
Sent: Tuesday, May 18, 2010 9:06 PM
To: solr-user@lucene.apache.org
Subject: RE: how to achieve filters

Hey

q=rock&fq:bitrate:[* TO 128]

bitrate is int
This also return docs with more then 128 bitrate, Is there something I am doing wrong 

Regards
prakash

-----Original Message-----
From: Doddamani, Prakash [mailto:prakash.doddamani@corp.aol.com]
Sent: Tuesday, May 18, 2010 8:44 PM
To: solr-user@lucene.apache.org
Subject: RE: how to achieve filters

Thanks much Ahmet,

Yep content is string, and bitrate is int.

I am digging more now Can we combine both the scenarios.

q=rock&fq={!field f=content}mp3
q=rock&fq:bitrate:[* TO 128]

Say if I want only mp3 from 0 to 128

Regards
Prakash

-----Original Message-----
From: Ahmet Arslan [mailto:iorixxx@yahoo.com]
Sent: Tuesday, May 18, 2010 8:24 PM
To: solr-user@lucene.apache.org
Subject: Re: how to achieve filters

> I am using "dismax" query to fetch docs from solr where I have set 
> some boost to the each fields,
> 
>  
> 
> If I search for query "Rock" I get following docs with some boost 
> value which I have specified,
> 
>  
> 
> <doc>
>   <float name="score">19.494072</float>
>   <int name="bitrate">120</int>
>   <str name="content">mp3</str>
>   <str name="genre">Rock</str>
>   <str name="id">1</str>
>   <str name="name">st name 1</str>
> </doc>
> <doc>
>   <float name="score">19.494052</float>
>   <int name="bitrate">248</int>
>   <str name="content">aac+</str>
>   <str name="genre">Rock</str>
>   <str name="id">2</str>
>   <str name="name">st name 2</str>
> </doc>
> <doc>
>   <float name="score">19.494042</float>
>   <int name="bitrate">127</int>
>   <str name="content">aac+</str>
>   <str name="genre">Rock</str>
>   <str name="id">3</str>
>   <str name="name">st name 3</str>
> </doc>
> <doc>
>   <float name="score">19.494032</float>
>   <int name="bitrate">256</int>
>   <str name="content">mp3</str>
>   <str name="genre">Rock</str>
>   <str name="id">4</str>
>   <str name="name">st name 5</str>
> </doc>
>  
> 
> I am looking for something below What is the best way to achieve them 
> ?

With filter queries. fq=

> 1. Query=rock where content= mp3 where it should return only first and 
> last docs where content=mp3

Assuming that content is string typed. q=rock&fq={!field f=content}mp3 

> 2. Query=rock where bitrate<128 where it should return only first and 
> third docs where bitrate<128

&q=rock&fq:bitrate:[* TO 128] for this bitrate field must be tint type.



      

RE: how to achieve filters

Posted by Ahmet Arslan <io...@yahoo.com>.
> q=rock&fq:bitrate:[* TO 128]
> 
> bitrate is int
> This also return docs with more then 128 bitrate, Is there
> something I am doing wrong 

If you are using solr 1.4.0 you need to use 

<fieldType name="tint" class="solr.TrieIntField" precisionStep="8" omitNorms="true" positionIncrementGap="0"

restart tomcat/reload core and re-index is necessary after that change.

q=rock&fq=bitrate:[* TO 128]


      

RE: how to achieve filters

Posted by "Doddamani, Prakash" <pr...@corp.aol.com>.
Hey

q=rock&fq:bitrate:[* TO 128]

bitrate is int
This also return docs with more then 128 bitrate, Is there something I am doing wrong 

Regards
prakash

-----Original Message-----
From: Doddamani, Prakash [mailto:prakash.doddamani@corp.aol.com] 
Sent: Tuesday, May 18, 2010 8:44 PM
To: solr-user@lucene.apache.org
Subject: RE: how to achieve filters

Thanks much Ahmet,

Yep content is string, and bitrate is int.

I am digging more now Can we combine both the scenarios.

q=rock&fq={!field f=content}mp3
q=rock&fq:bitrate:[* TO 128]

Say if I want only mp3 from 0 to 128

Regards
Prakash

-----Original Message-----
From: Ahmet Arslan [mailto:iorixxx@yahoo.com]
Sent: Tuesday, May 18, 2010 8:24 PM
To: solr-user@lucene.apache.org
Subject: Re: how to achieve filters

> I am using "dismax" query to fetch docs from solr where I have set 
> some boost to the each fields,
> 
>  
> 
> If I search for query "Rock" I get following docs with some boost 
> value which I have specified,
> 
>  
> 
> <doc>
>   <float name="score">19.494072</float>
>   <int name="bitrate">120</int>
>   <str name="content">mp3</str>
>   <str name="genre">Rock</str>
>   <str name="id">1</str>
>   <str name="name">st name 1</str>
> </doc>
> <doc>
>   <float name="score">19.494052</float>
>   <int name="bitrate">248</int>
>   <str name="content">aac+</str>
>   <str name="genre">Rock</str>
>   <str name="id">2</str>
>   <str name="name">st name 2</str>
> </doc>
> <doc>
>   <float name="score">19.494042</float>
>   <int name="bitrate">127</int>
>   <str name="content">aac+</str>
>   <str name="genre">Rock</str>
>   <str name="id">3</str>
>   <str name="name">st name 3</str>
> </doc>
> <doc>
>   <float name="score">19.494032</float>
>   <int name="bitrate">256</int>
>   <str name="content">mp3</str>
>   <str name="genre">Rock</str>
>   <str name="id">4</str>
>   <str name="name">st name 5</str>
> </doc>
>  
> 
> I am looking for something below What is the best way to achieve them 
> ?

With filter queries. fq=

> 1. Query=rock where content= mp3 where it should return only first and 
> last docs where content=mp3

Assuming that content is string typed. q=rock&fq={!field f=content}mp3 

> 2. Query=rock where bitrate<128 where it should return only first and 
> third docs where bitrate<128

&q=rock&fq:bitrate:[* TO 128] for this bitrate field must be tint type.



      

RE: how to achieve filters

Posted by Ahmet Arslan <io...@yahoo.com>.
> Yep content is string, and bitrate is int.

bitrate should be trie based tint, not int, for range queries work correctly.

> I am digging more now Can we combine both the scenarios.
> 
> q=rock&fq={!field f=content}mp3 
> q=rock&fq:bitrate:[* TO 128]
> 
> Say if I want only mp3 from 0 to 128

You can append filter queries (fq) as many as you want. 

&q=rock&fq={!field f=content}mp3&fq=bitrate:[* TO 128]




      

RE: how to achieve filters

Posted by "Doddamani, Prakash" <pr...@corp.aol.com>.
Thanks much Ahmet,

Yep content is string, and bitrate is int.

I am digging more now Can we combine both the scenarios.

q=rock&fq={!field f=content}mp3 
q=rock&fq:bitrate:[* TO 128]

Say if I want only mp3 from 0 to 128

Regards
Prakash

-----Original Message-----
From: Ahmet Arslan [mailto:iorixxx@yahoo.com] 
Sent: Tuesday, May 18, 2010 8:24 PM
To: solr-user@lucene.apache.org
Subject: Re: how to achieve filters

> I am using "dismax" query to fetch docs from solr where I have set 
> some boost to the each fields,
> 
>  
> 
> If I search for query "Rock" I get following docs with some boost 
> value which I have specified,
> 
>  
> 
> <doc>
>   <float name="score">19.494072</float>
>   <int name="bitrate">120</int>
>   <str name="content">mp3</str>
>   <str name="genre">Rock</str>
>   <str name="id">1</str>
>   <str name="name">st name 1</str>
> </doc>
> <doc>
>   <float name="score">19.494052</float>
>   <int name="bitrate">248</int>
>   <str name="content">aac+</str>
>   <str name="genre">Rock</str>
>   <str name="id">2</str>
>   <str name="name">st name 2</str>
> </doc>
> <doc>
>   <float name="score">19.494042</float>
>   <int name="bitrate">127</int>
>   <str name="content">aac+</str>
>   <str name="genre">Rock</str>
>   <str name="id">3</str>
>   <str name="name">st name 3</str>
> </doc>
> <doc>
>   <float name="score">19.494032</float>
>   <int name="bitrate">256</int>
>   <str name="content">mp3</str>
>   <str name="genre">Rock</str>
>   <str name="id">4</str>
>   <str name="name">st name 5</str>
> </doc>
>  
> 
> I am looking for something below What is the best way to achieve them 
> ?

With filter queries. fq=

> 1. Query=rock where content= mp3 where it should return only first and 
> last docs where content=mp3

Assuming that content is string typed. q=rock&fq={!field f=content}mp3 

> 2. Query=rock where bitrate<128 where it should return only first and 
> third docs where bitrate<128

&q=rock&fq:bitrate:[* TO 128] for this bitrate field must be tint type.



      

Re: how to achieve filters

Posted by Michael Kuhlmann <mi...@zalando.de>.
Am 18.05.2010 16:54, schrieb Ahmet Arslan:
>> 2. Query=rock where bitrate<128 where it should return
>> only first and third docs where bitrate<128
> 
> &q=rock&fq:bitrate:[* TO 128] for this bitrate field must be tint type.
> 

&q=rock&fq:bitrate:[* TO 127] would be better, because bitrate should be
lower than 128.

BTW, a bitrate of 127 is interesting...

@Prakash:
See http://wiki.apache.org/solr/SolrFacetingOverview

Re: how to achieve filters

Posted by Ahmet Arslan <io...@yahoo.com>.
> I am using "dismax" query to fetch docs from solr where I
> have set some
> boost to the each fields,
> 
>  
> 
> If I search for query "Rock" I get following docs with some
> boost value
> which I have specified,
> 
>  
> 
> <doc>
>   <float name="score">19.494072</float>
>   <int name="bitrate">120</int>
>   <str name="content">mp3</str>
>   <str name="genre">Rock</str>
>   <str name="id">1</str>
>   <str name="name">st name 1</str>
> </doc>
> <doc>
>   <float name="score">19.494052</float>
>   <int name="bitrate">248</int>
>   <str name="content">aac+</str>
>   <str name="genre">Rock</str>
>   <str name="id">2</str>
>   <str name="name">st name 2</str>
> </doc>
> <doc>
>   <float name="score">19.494042</float>
>   <int name="bitrate">127</int>
>   <str name="content">aac+</str>
>   <str name="genre">Rock</str>
>   <str name="id">3</str>
>   <str name="name">st name 3</str>
> </doc>
> <doc>
>   <float name="score">19.494032</float>
>   <int name="bitrate">256</int>
>   <str name="content">mp3</str>
>   <str name="genre">Rock</str>
>   <str name="id">4</str>
>   <str name="name">st name 5</str>
> </doc>
>  
> 
> I am looking for something below What is the best way to
> achieve them ?

With filter queries. fq=

> 1. Query=rock where content= mp3 where it should return
> only first and
> last docs where content=mp3

Assuming that content is string typed. q=rock&fq={!field f=content}mp3 

> 2. Query=rock where bitrate<128 where it should return
> only first and third docs where bitrate<128

&q=rock&fq:bitrate:[* TO 128] for this bitrate field must be tint type.