Groups and faceting are orthogonal and really have nothing to do with
each other, so that might be where part of the problem lies.

In your example, you can consider grouping by brand and count the
*groups* returned, not elements within those groups. Then you're
simply counting up the groups returned in the response packet. Note
that this is NOT the stuff down in the "facets" section. You can still
facet by color just as you are.

Another possibility is to look at "pivot faceting":
https://issues.apache.org/jira/browse/SOLR-792
but I confess I haven't explored this so don't really understand if it
applies to your problem.

Best
Erick

On Mon, Mar 19, 2012 at 5:22 AM, Rasmus Østergård <r...@vertica.dk> wrote:
> I have an index that contains variants of cars. In this small sample I have 2 
> car models (Audi and Volvo) and the Audi is available in black or white, 
> whereas the Volvo is only available in black.
>
> On the search page I want to display products not variants - in this test 
> case 2 products should be shown: "Audi A4" and "Volvo V50"
>
> I'm having trouble achieving the desired count in my search facets.
>
> This is my test schema:
>
> <fields>
>   <field name=" variant_id" type="string" indexed="true" stored="true" 
> required="true" />
>   <field name="sku" type="string" indexed="true" stored="true" />
>   <field name="color" type="string" indexed="true" stored="true"/>
>  </fields>
> <uniqueKey>variant_id</uniqueKey>
>
> Test data:
>
> <doc>
> <field name="sku">Audi A4</field>
> <field name="brand">audi</field>
> <!-- Variant properties -->
> <field name="variant_id">A4_black</field>
> <field name="color">black</field>
> </doc>
> <doc>
> <field name="sku">Audi A4</field>
> <field name="brand">audi</field>
> <!-- Variant properties -->
> <field name="variant_id">A4_white</field>
> <field name="color">white</field>
> </doc>
> <doc>
> <field name="sku">Volvo V50</field>
> <field name="brand">volvo</field>
> <!-- Variant properties -->
> <field name="variant_id">Volvo_V50</field>
> <field name="color">black</field>
> </doc>
>
> My goal is to to get this facet:
> brand
> -------------
> audi (1)
> volvo (1)
>
> color
> -------------
> black (2)
> white (1)
>
>
> I'm trying to use group.truncate to do this but fails.
>
> This is my search query when not truncating:
> /select?facet.field=color&facet.field=brand&defType=edixmax&facet=true&group=true&group.field=sku&group.truncate=false
>
> brand
> -------------
> audi (2)
> volvo (1)
>
> color
> -------------
> black (2)
> white (1)
>
>
> This is my search query when doing truncating:
> /select?facet.field=color&facet.field=brand&defType=edixmax&facet=true&group=true&group.field=sku&group.truncate=true
>
> brand
> -------------
> audi (1)
> volvo (1)
>
> color
> -------------
> black (2)
> white (0)
>
>
> As can be seen none of the 2 above match my desire.
> The problem seems to be that I want trucating on only selected facets. I this 
> posible?
>
> Thanks!

Reply via email to