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 ashokcz <as...@tcs.com> on 2009/07/16 09:49:26 UTC

Getting Facet Count of combination of fields

Hi all,
i have a scenario where i need to get facet count for combination of fields.
Say i have two fields Manufacturer and Year of manufacture.
I search for something and it gives me 15 results and my facet count as like
this :
Manufacturer           : Nokia(5);Motorola(7);iphone(3)
Year of manufacture : 2007 (4) ; 2008 (4) 2009 (7).
But what i need is combination of count .
Say 
Nokia - 2007 - 1
Nokia - 2008 - 1
Nokia - 2009 - 2

Somethig like this ........


is there any way we can get this kind of facet counts from single solr
search hits ???




-- 
View this message in context: http://www.nabble.com/Getting-Facet-Count-of-combination-of-fields-tp24511923p24511923.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: Getting Facet Count of combination of fields

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On Jul 16, 2009, at 4:35 AM, Koji Sekiguchi wrote:

> ashokcz wrote:
>> Hi all,
>> i have a scenario where i need to get facet count for combination  
>> of fields.
>> Say i have two fields Manufacturer and Year of manufacture.
>> I search for something and it gives me 15 results and my facet  
>> count as like
>> this :
>> Manufacturer           : Nokia(5);Motorola(7);iphone(3)
>> Year of manufacture : 2007 (4) ; 2008 (4) 2009 (7).
>> But what i need is combination of count .
>> Say Nokia - 2007 - 1
>> Nokia - 2008 - 1
>> Nokia - 2009 - 2
>>
>> Somethig like this ........
>>
>>
>> is there any way we can get this kind of facet counts from single  
>> solr
>> search hits ???
>>
>>
>
> Are you looking at this?
> https://issues.apache.org/jira/browse/SOLR-792

A note on SOLR-792 - it's something that can be accomplished from the  
client by making multiple requests to Solr.  First facet on  
Manufacturer, iterate through each and request facets on Year with an  
fq (filter query) set for each Manufacturer.

	Erik


Re: Getting Facet Count of combination of fields

Posted by ashokcz <as...@tcs.com>.
hmmm thanks Koji :handshake: will trymy hands on 1.4 version and see my luck
=^D

Koji Sekiguchi-2 wrote:
> 
> ashokcz wrote:
>> Hi thanks "Koji Sekiguchi-2" for your reply .
>> Ya i was looking something like that .
>> So when doing the solrrequest is should have extra config parameters
>> facet.tree and i shud give the fields csv to specify the hierarchy ....
>> will
>> try and see if its giving me desired results .
>> But just one doubt i am using Solr-1.2.0 Version . is this feature
>> present
>> in Solr-1.2.0 Version ??
>> thanks .
>>
>>   
> Unfortunately, no. I think it will be 1.4 or later.
> 
> Koji
> 
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Getting-Facet-Count-of-combination-of-fields-tp24511923p24513763.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: Getting Facet Count of combination of fields

Posted by Koji Sekiguchi <ko...@r.email.ne.jp>.
ashokcz wrote:
> Hi thanks "Koji Sekiguchi-2" for your reply .
> Ya i was looking something like that .
> So when doing the solrrequest is should have extra config parameters
> facet.tree and i shud give the fields csv to specify the hierarchy .... will
> try and see if its giving me desired results .
> But just one doubt i am using Solr-1.2.0 Version . is this feature present
> in Solr-1.2.0 Version ??
> thanks .
>
>   
Unfortunately, no. I think it will be 1.4 or later.

Koji



Re: Getting Facet Count of combination of fields

Posted by ashokcz <as...@tcs.com>.
Hi thanks "Koji Sekiguchi-2" for your reply .
Ya i was looking something like that .
So when doing the solrrequest is should have extra config parameters
facet.tree and i shud give the fields csv to specify the hierarchy .... will
try and see if its giving me desired results .
But just one doubt i am using Solr-1.2.0 Version . is this feature present
in Solr-1.2.0 Version ??
thanks .




Koji Sekiguchi-2 wrote:
> 
> ashokcz wrote:
>> Hi all,
>> i have a scenario where i need to get facet count for combination of
>> fields.
>> Say i have two fields Manufacturer and Year of manufacture.
>> I search for something and it gives me 15 results and my facet count as
>> like
>> this :
>> Manufacturer           : Nokia(5);Motorola(7);iphone(3)
>> Year of manufacture : 2007 (4) ; 2008 (4) 2009 (7).
>> But what i need is combination of count .
>> Say 
>> Nokia - 2007 - 1
>> Nokia - 2008 - 1
>> Nokia - 2009 - 2
>>
>> Somethig like this ........
>>
>>
>> is there any way we can get this kind of facet counts from single solr
>> search hits ???
>>
>>   
> 
> Are you looking at this?
> https://issues.apache.org/jira/browse/SOLR-792
> 
> Koji
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Getting-Facet-Count-of-combination-of-fields-tp24511923p24512961.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: Getting Facet Count of combination of fields

Posted by Koji Sekiguchi <ko...@r.email.ne.jp>.
ashokcz wrote:
> Hi all,
> i have a scenario where i need to get facet count for combination of fields.
> Say i have two fields Manufacturer and Year of manufacture.
> I search for something and it gives me 15 results and my facet count as like
> this :
> Manufacturer           : Nokia(5);Motorola(7);iphone(3)
> Year of manufacture : 2007 (4) ; 2008 (4) 2009 (7).
> But what i need is combination of count .
> Say 
> Nokia - 2007 - 1
> Nokia - 2008 - 1
> Nokia - 2009 - 2
>
> Somethig like this ........
>
>
> is there any way we can get this kind of facet counts from single solr
> search hits ???
>
>   

Are you looking at this?
https://issues.apache.org/jira/browse/SOLR-792

Koji


Re: Getting Facet Count of combination of fields

Posted by Brian Johnson <br...@yahoo.com>.
An interesting analogy for this feature is that you're doing a count(*) on a group by in SQL. While it's true that you can pre-compute these if you have a small set of combination you know you want to show a-priori, if you want to present a more dynamic customer experience, you need to be able to run these on arbitrary combination of fields at query time. I would like to see support for aggregating functions beyond just a count. Here's a sample list of what's available in mysql: http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html

Looking at the patch in SOLR-792, it doesn't look terribly difficult to add function level abstraction and to go beyond 2 levels. I have some code that does this but it's implemented as an ant task and wired to a CSV parser. I'll see what it would take to refactor it...

What would you imagine the query looking like if functions were added?

http://localhost:8983/solr/select?q=*:*&rows=0&facet=on&facet.field=cat&facet.tree=cat,inStock{count},price{min,average,max}&wt=json&indent=on

It also gets very interesting when you want to start filtering, sorting and managing response sizes on the facet values such as this quickly contrived example: facet.tree=cat,inStock{return the first 10 counts greater than 5 descending sorted}

Brian





________________________________
From: ashokcz <as...@tcs.com>
To: solr-user@lucene.apache.org
Sent: Thursday, July 16, 2009 3:22:48 AM
Subject: Re: Getting Facet Count of combination of fields


hmmm but in my case it will be dynamic . they may choose different fields at
run time and accordingly i need to populate the values ...

Avlesh Singh wrote:
> 
> If you create a field called "brand_year_of_manufacturing" and populate it
> with the "brandName - YOM" data while indexing, you can achieve the
> desired
> with a simple facet on this field.
> 
> Cheers
> Avlesh
> 
> On Thu, Jul 16, 2009 at 1:19 PM, ashokcz <as...@tcs.com>
> wrote:
> 
>>
>> Hi all,
>> i have a scenario where i need to get facet count for combination of
>> fields.
>> Say i have two fields Manufacturer and Year of manufacture.
>> I search for something and it gives me 15 results and my facet count as
>> like
>> this :
>> Manufacturer           : Nokia(5);Motorola(7);iphone(3)
>> Year of manufacture : 2007 (4) ; 2008 (4) 2009 (7).
>> But what i need is combination of count .
>> Say
>> Nokia - 2007 - 1
>> Nokia - 2008 - 1
>> Nokia - 2009 - 2
>>
>> Somethig like this ........
>>
>>
>> is there any way we can get this kind of facet counts from single solr
>> search hits ???
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Getting-Facet-Count-of-combination-of-fields-tp24511923p24511923.html
>> Sent from the Solr - User mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/Getting-Facet-Count-of-combination-of-fields-tp24511923p24513837.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Getting Facet Count of combination of fields

Posted by ashokcz <as...@tcs.com>.
hmmm but in my case it will be dynamic . they may choose different fields at
run time and accordingly i need to populate the values ...

Avlesh Singh wrote:
> 
> If you create a field called "brand_year_of_manufacturing" and populate it
> with the "brandName - YOM" data while indexing, you can achieve the
> desired
> with a simple facet on this field.
> 
> Cheers
> Avlesh
> 
> On Thu, Jul 16, 2009 at 1:19 PM, ashokcz <as...@tcs.com>
> wrote:
> 
>>
>> Hi all,
>> i have a scenario where i need to get facet count for combination of
>> fields.
>> Say i have two fields Manufacturer and Year of manufacture.
>> I search for something and it gives me 15 results and my facet count as
>> like
>> this :
>> Manufacturer           : Nokia(5);Motorola(7);iphone(3)
>> Year of manufacture : 2007 (4) ; 2008 (4) 2009 (7).
>> But what i need is combination of count .
>> Say
>> Nokia - 2007 - 1
>> Nokia - 2008 - 1
>> Nokia - 2009 - 2
>>
>> Somethig like this ........
>>
>>
>> is there any way we can get this kind of facet counts from single solr
>> search hits ???
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Getting-Facet-Count-of-combination-of-fields-tp24511923p24511923.html
>> Sent from the Solr - User mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/Getting-Facet-Count-of-combination-of-fields-tp24511923p24513837.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: Getting Facet Count of combination of fields

Posted by Avlesh Singh <av...@gmail.com>.
If you create a field called "brand_year_of_manufacturing" and populate it
with the "brandName - YOM" data while indexing, you can achieve the desired
with a simple facet on this field.

Cheers
Avlesh

On Thu, Jul 16, 2009 at 1:19 PM, ashokcz <as...@tcs.com> wrote:

>
> Hi all,
> i have a scenario where i need to get facet count for combination of
> fields.
> Say i have two fields Manufacturer and Year of manufacture.
> I search for something and it gives me 15 results and my facet count as
> like
> this :
> Manufacturer           : Nokia(5);Motorola(7);iphone(3)
> Year of manufacture : 2007 (4) ; 2008 (4) 2009 (7).
> But what i need is combination of count .
> Say
> Nokia - 2007 - 1
> Nokia - 2008 - 1
> Nokia - 2009 - 2
>
> Somethig like this ........
>
>
> is there any way we can get this kind of facet counts from single solr
> search hits ???
>
>
>
>
> --
> View this message in context:
> http://www.nabble.com/Getting-Facet-Count-of-combination-of-fields-tp24511923p24511923.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>
>