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