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 Sumit Aggarwal <su...@gmail.com> on 2009/07/01 14:31:47 UTC

Question on Facet Count

Suppose i wanted to search for red dress and i want to get facet count for
term size-medium, size-large... Basically i wanted to get facet count for
some predefined terms in result set. How can i do it?
once i got facet count now i want result set for red dress and size-medium.
i hope i can achive this using facet filter query.....

Re: Question on Facet Count

Posted by Shalin Shekhar Mangar <sh...@gmail.com>.
On Wed, Jul 1, 2009 at 10:28 PM, Sumit Aggarwal
<su...@gmail.com>wrote:

> Hi Shalin,
> Sorry for the confusion but i dont have separate index fields. I have all
> information in only one index field descp. Now is it possible what you
> explained.
>
>
No, you should separate out the data in multiple fields for this to work.
One big field containing everything is ok for full text search but you can't
build a faceted search on that.

-- 
Regards,
Shalin Shekhar Mangar.

Re: Question on Facet Count

Posted by Sumit Aggarwal <su...@gmail.com>.
Hi Shalin,
Sorry for the confusion but i dont have separate index fields. I have all
information in only one index field descp. Now is it possible what you
explained.

Thanks,
Sumit

On Wed, Jul 1, 2009 at 10:16 PM, Shalin Shekhar Mangar <
shalinmangar@gmail.com> wrote:

> On Wed, Jul 1, 2009 at 10:01 PM, Sumit Aggarwal
> <su...@gmail.com>wrote:
>
> > Hi Shalin,
> > specifying facet.query='small'&facet.query=large will actually filter the
> > result also.....and it wont give me facet count for both at the same
> > time...
> > i will give total resultset for both these terms.
>
>
> No. facet.query will not filter the results. It is applied on top of the
> current result set (the documents matching your q and fq parameters). If
> you
> specify multiple facet.query parameters, you will get a count for each of
> them.
>
>
> >  since i am very new to
> > solr so i dont understand how facet counting behaves in that case as i
> have
> > seen lots of website showning facet count for multiple terms like amazon
> > does ... in amazon if i search laptop on left pane it shows me count of
> > each
> > brands as well as count of display sizes also but showing total result
> set
> > for query laptop on right section. so they would be doing it.... i am
> > assuming this must be some simple task.
> >
>
> I guess that's just simple facet.field in play. You have only fixed set of
> sizes in your field 'x', so you do a facet.field=x and you get a count for
> each term in field 'x'.
>
>
> >
> > Here is example for my req:
> > 1. i wanted to search "red dress"...
> >
> > left section has some filters like size as "small", "large", brands as
> > Versace,Marc Jacobs.......
> >
> > As i fire this query it should return me all result matched  as "red
> dress"
> > on right section and i should get count of small, large, versace, Marc
> > Jacobs..... considering i am having all information in a single field as
> > descp index field... After that if i select "large" i should get result
> > matching as both "red dress" and "large"
> >
> >
> Right, that's stock faceted search. For the scenario you have described,
> you
> can do q=red dress&facet=true&facet.field=size&facet.field=brands and so on
> for each field you want to use as a facet.
>
> When a user clicks on a facet value say "versace", you make a query like
> q=red dress&*fq=brand:versace*&facet=true&facet.field=size and so on for
> all
> fields you want to use as a facet (note, unless 'brand' is a multi-valued
> field, there is no need to include facet.field=brand because a value has
> already been selected and facet.field won't match anything)
>
> --
> Regards,
> Shalin Shekhar Mangar.
>

Re: Question on Facet Count

Posted by Shalin Shekhar Mangar <sh...@gmail.com>.
On Wed, Jul 1, 2009 at 10:01 PM, Sumit Aggarwal
<su...@gmail.com>wrote:

> Hi Shalin,
> specifying facet.query='small'&facet.query=large will actually filter the
> result also.....and it wont give me facet count for both at the same
> time...
> i will give total resultset for both these terms.


No. facet.query will not filter the results. It is applied on top of the
current result set (the documents matching your q and fq parameters). If you
specify multiple facet.query parameters, you will get a count for each of
them.


>  since i am very new to
> solr so i dont understand how facet counting behaves in that case as i have
> seen lots of website showning facet count for multiple terms like amazon
> does ... in amazon if i search laptop on left pane it shows me count of
> each
> brands as well as count of display sizes also but showing total result set
> for query laptop on right section. so they would be doing it.... i am
> assuming this must be some simple task.
>

I guess that's just simple facet.field in play. You have only fixed set of
sizes in your field 'x', so you do a facet.field=x and you get a count for
each term in field 'x'.


>
> Here is example for my req:
> 1. i wanted to search "red dress"...
>
> left section has some filters like size as "small", "large", brands as
> Versace,Marc Jacobs.......
>
> As i fire this query it should return me all result matched  as "red dress"
> on right section and i should get count of small, large, versace, Marc
> Jacobs..... considering i am having all information in a single field as
> descp index field... After that if i select "large" i should get result
> matching as both "red dress" and "large"
>
>
Right, that's stock faceted search. For the scenario you have described, you
can do q=red dress&facet=true&facet.field=size&facet.field=brands and so on
for each field you want to use as a facet.

When a user clicks on a facet value say "versace", you make a query like
q=red dress&*fq=brand:versace*&facet=true&facet.field=size and so on for all
fields you want to use as a facet (note, unless 'brand' is a multi-valued
field, there is no need to include facet.field=brand because a value has
already been selected and facet.field won't match anything)

-- 
Regards,
Shalin Shekhar Mangar.

Re: Question on Facet Count

Posted by Sumit Aggarwal <su...@gmail.com>.
Hi Shalin,
specifying facet.query='small'&facet.query=large will actually filter the
result also.....and it wont give me facet count for both at the same time...
i will give total resultset for both these terms.  since i am very new to
solr so i dont understand how facet counting behaves in that case as i have
seen lots of website showning facet count for multiple terms like amazon
does ... in amazon if i search laptop on left pane it shows me count of each
brands as well as count of display sizes also but showing total result set
for query laptop on right section. so they would be doing it.... i am
assuming this must be some simple task.

Here is example for my req:
1. i wanted to search "red dress"...

left section has some filters like size as "small", "large", brands as
Versace,Marc Jacobs.......

As i fire this query it should return me all result matched  as "red dress"
on right section and i should get count of small, large, versace, Marc
Jacobs..... considering i am having all information in a single field as
descp index field... After that if i select "large" i should get result
matching as both "red dress" and "large"


Thanks,
Sumit

Thanks,
Sumit

On Wed, Jul 1, 2009 at 9:43 PM, Shalin Shekhar Mangar <
shalinmangar@gmail.com> wrote:

> On Wed, Jul 1, 2009 at 9:42 PM, Shalin Shekhar Mangar <
> shalinmangar@gmail.com> wrote:
>
> > On Wed, Jul 1, 2009 at 8:25 PM, Sumit Aggarwal <
> sumit.kaggarwal@gmail.com>wrote:
> >
> >> The example given says i can specify only one term as facet prefix. My
> >> Requirement is i should be able to pass few set of facet terms which
> will
> >> return me facet count for those terms only..
> >>
> >> So i wanted to do some thing like....
> >> q=red dress
> >> facet=true
> >> facet.field=descp
> >> facet.mincount=1
> >> facet.prefix=['small','large','macys.com']            (here number of
> >> facet
> >> terms are more than one)
> >>
> >>
> > I think what you need is facet.query. You'll need to send multiple
> > facet.query parameters like facet.query=small*&facet.query=large* and so
> on.
> >
>
>
> Note that this won't give you the matching terms but it will give you a
> count of documents matching the facet.query.
>
>
> --
> Regards,
> Shalin Shekhar Mangar.
>

Re: Question on Facet Count

Posted by Shalin Shekhar Mangar <sh...@gmail.com>.
On Wed, Jul 1, 2009 at 9:42 PM, Shalin Shekhar Mangar <
shalinmangar@gmail.com> wrote:

> On Wed, Jul 1, 2009 at 8:25 PM, Sumit Aggarwal <su...@gmail.com>wrote:
>
>> The example given says i can specify only one term as facet prefix. My
>> Requirement is i should be able to pass few set of facet terms which will
>> return me facet count for those terms only..
>>
>> So i wanted to do some thing like....
>> q=red dress
>> facet=true
>> facet.field=descp
>> facet.mincount=1
>> facet.prefix=['small','large','macys.com']            (here number of
>> facet
>> terms are more than one)
>>
>>
> I think what you need is facet.query. You'll need to send multiple
> facet.query parameters like facet.query=small*&facet.query=large* and so on.
>


Note that this won't give you the matching terms but it will give you a
count of documents matching the facet.query.


-- 
Regards,
Shalin Shekhar Mangar.

Re: Question on Facet Count

Posted by Shalin Shekhar Mangar <sh...@gmail.com>.
On Wed, Jul 1, 2009 at 8:25 PM, Sumit Aggarwal <su...@gmail.com>wrote:

> The example given says i can specify only one term as facet prefix. My
> Requirement is i should be able to pass few set of facet terms which will
> return me facet count for those terms only..
>
> So i wanted to do some thing like....
> q=red dress
> facet=true
> facet.field=descp
> facet.mincount=1
> facet.prefix=['small','large','macys.com']            (here number of
> facet
> terms are more than one)
>
>
I think what you need is facet.query. You'll need to send multiple
facet.query parameters like facet.query=small*&facet.query=large* and so on.

-- 
Regards,
Shalin Shekhar Mangar.

Re: Question on Facet Count

Posted by Sumit Aggarwal <su...@gmail.com>.
Hi Bill,
The example given says i can specify only one term as facet prefix. My
Requirement is i should be able to pass few set of facet terms which will
return me facet count for those terms only..

So i wanted to do some thing like....
q=red dress
facet=true
facet.field=descp
facet.mincount=1
facet.prefix=['small','large','macys.com']            (here number of facet
terms are more than one)

Can you please give some in sight...

Thanks,
Sumit

On Wed, Jul 1, 2009 at 7:28 PM, Bill Au <bi...@gmail.com> wrote:

> You can use a facet query.  Here is an example from the Solr Wiki:
>
>
> http://wiki.apache.org/solr/SimpleFacetParameters#head-1da3ab3995bc4abcdce8e0f04be7355ba19e9b2c
>
> Bill
>
> On Wed, Jul 1, 2009 at 8:34 AM, Sumit Aggarwal <sumit.kaggarwal@gmail.com
> >wrote:
>
> > >
> > > Suppose i wanted to search for red dress and i want to get facet count
> > for
> > > term size-medium, size-large... Basically i wanted to get facet count
> for
> > > some predefined terms in result set. How can i do it?
> > > once i got facet count now i want result set for red dress and
> > size-medium.
> > > i hope i can achive this using facet filter query.....
> > >
> >
> > Thanks,
> > Sumit
> >
>

Re: Question on Facet Count

Posted by Bill Au <bi...@gmail.com>.
You can use a facet query.  Here is an example from the Solr Wiki:

http://wiki.apache.org/solr/SimpleFacetParameters#head-1da3ab3995bc4abcdce8e0f04be7355ba19e9b2c

Bill

On Wed, Jul 1, 2009 at 8:34 AM, Sumit Aggarwal <su...@gmail.com>wrote:

> >
> > Suppose i wanted to search for red dress and i want to get facet count
> for
> > term size-medium, size-large... Basically i wanted to get facet count for
> > some predefined terms in result set. How can i do it?
> > once i got facet count now i want result set for red dress and
> size-medium.
> > i hope i can achive this using facet filter query.....
> >
>
> Thanks,
> Sumit
>

Re: Question on Facet Count

Posted by Sumit Aggarwal <su...@gmail.com>.
>
> Suppose i wanted to search for red dress and i want to get facet count for
> term size-medium, size-large... Basically i wanted to get facet count for
> some predefined terms in result set. How can i do it?
> once i got facet count now i want result set for red dress and size-medium.
> i hope i can achive this using facet filter query.....
>

Thanks,
Sumit