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 Matthew Runo <mr...@zappos.com> on 2007/05/03 00:55:50 UTC

Group results by field?

Hello!

I was wondering - is it possible to search and group the results by a  
given field?

For example, I have an index with several million records. Most of  
them are different sizes of the same style_id.

I'd love to be able to do.. group.by=style_id or something like that  
in the results, and provide the style_id as a clickable link to see  
all the sizes of that style.

Any ideas?

+--------------------------------------------------------+
  | Matthew Runo
  | Zappos Development
  | mruno@zappos.com
  | 702-943-7833
+--------------------------------------------------------+



Re: Group results by field?

Posted by Matthew Runo <mr...@zappos.com>.
Right now, each style/size is a separate document.

I agree, it makes far more sense to have each size be associates with  
only one style. I think I'll pursue that route at first here, and  
then for grouping similar items I may have to do some facet magic  
(facets to show links for product_category/brand/color while at the  
same time presenting only one thumbnail with a list of the sizes  
available.. etc etc).

+--------------------------------------------------------+
  | Matthew Runo
  | Zappos Development
  | mruno@zappos.com
  | 702-943-7833
+--------------------------------------------------------+


On May 2, 2007, at 4:15 PM, Tom Hill wrote:

> Hi Matthew,
>
> You might be able to just get away with just using facets,  
> depending on
> whether your goal is to provide a clickable list of styles_ids to  
> the user,
> or if you want to only return one search result for each style_id.
>
> For a list of clickable styles, it's basic faceting, and works  
> really well.
>
> http://wiki.apache.org/solr/SimpleFacetParameters
> Facet on style_id, present the list of facets to the user, and if  
> the user
> selects style_id =37, then reissue the query with one more clause
> (+style_id:37)
>
> If you want the ability to only show one search result from each  
> group, then
> you might consider the structure of your data. Is each style/size a  
> separate
> record? Or is each style a record with multi-valued sizes? The  
> latter might
> give you what you really want.
>
> Or, if you really want to remove dups from search results, you  
> could do what
> I've done.I ended up modifying SolrIndexSearcher, and replacing
> FieldSortedHitQueue, and ScorePriorityQueue with versions that  
> remove dups
> based in a particular field.
>
> Tom
>
>
> On 5/2/07, Matthew Runo <mr...@zappos.com> wrote:
>>
>> Hello!
>>
>> I was wondering - is it possible to search and group the results by a
>> given field?
>>
>> For example, I have an index with several million records. Most of
>> them are different sizes of the same style_id.
>>
>> I'd love to be able to do.. group.by=style_id or something like that
>> in the results, and provide the style_id as a clickable link to see
>> all the sizes of that style.
>>
>> Any ideas?
>>
>> +--------------------------------------------------------+
>>   | Matthew Runo
>>   | Zappos Development
>>   | mruno@zappos.com
>>   | 702-943-7833
>> +--------------------------------------------------------+
>>
>>
>>


Re: Group results by field?

Posted by Tom Hill <so...@zvents.com>.
Hi Matthew,

You might be able to just get away with just using facets, depending on
whether your goal is to provide a clickable list of styles_ids to the user,
or if you want to only return one search result for each style_id.

For a list of clickable styles, it's basic faceting, and works really well.

http://wiki.apache.org/solr/SimpleFacetParameters
Facet on style_id, present the list of facets to the user, and if the user
selects style_id =37, then reissue the query with one more clause
(+style_id:37)

If you want the ability to only show one search result from each group, then
you might consider the structure of your data. Is each style/size a separate
record? Or is each style a record with multi-valued sizes? The latter might
give you what you really want.

Or, if you really want to remove dups from search results, you could do what
I've done.I ended up modifying SolrIndexSearcher, and replacing
FieldSortedHitQueue, and ScorePriorityQueue with versions that remove dups
based in a particular field.

Tom


On 5/2/07, Matthew Runo <mr...@zappos.com> wrote:
>
> Hello!
>
> I was wondering - is it possible to search and group the results by a
> given field?
>
> For example, I have an index with several million records. Most of
> them are different sizes of the same style_id.
>
> I'd love to be able to do.. group.by=style_id or something like that
> in the results, and provide the style_id as a clickable link to see
> all the sizes of that style.
>
> Any ideas?
>
> +--------------------------------------------------------+
>   | Matthew Runo
>   | Zappos Development
>   | mruno@zappos.com
>   | 702-943-7833
> +--------------------------------------------------------+
>
>
>

Re: Group results by field?

Posted by Matthew Runo <mr...@zappos.com>.
Ahh, ok.

I'll check out Saxon-B and XSLT templates.

+--------------------------------------------------------+
  | Matthew Runo
  | Zappos Development
  | mruno@zappos.com
  | 702-943-7833
+--------------------------------------------------------+


On May 2, 2007, at 3:57 PM, Brian Whitman wrote:

> On May 2, 2007, at 6:55 PM, Matthew Runo wrote:
>
>> I was wondering - is it possible to search and group the results  
>> by a given field?
>>
>> For example, I have an index with several million records. Most of  
>> them are different sizes of the same style_id.
>>
>> I'd love to be able to do.. group.by=style_id or something like  
>> that in the results, and provide the style_id as a clickable link  
>> to see all the sizes of that style.
>
>
> As far as I know there's no in-Solr grouping mechanism. But we use  
> the XSLTResponseWriter for this:
>
> http://wiki.apache.org/solr/XsltResponseWriter (look near the bottom)
>
>
>


Re: Group results by field?

Posted by Brian Whitman <br...@variogr.am>.
On May 2, 2007, at 6:55 PM, Matthew Runo wrote:

> I was wondering - is it possible to search and group the results by  
> a given field?
>
> For example, I have an index with several million records. Most of  
> them are different sizes of the same style_id.
>
> I'd love to be able to do.. group.by=style_id or something like  
> that in the results, and provide the style_id as a clickable link  
> to see all the sizes of that style.


As far as I know there's no in-Solr grouping mechanism. But we use  
the XSLTResponseWriter for this:

http://wiki.apache.org/solr/XsltResponseWriter (look near the bottom)