> Every product we have comes in colour and size combinations,
> I need to do a
> faceted search on these that allows for colour and size and
> various other
> fields. A single product may have multiple colours and multiple sizes.
>
> For example a style might be available in black size 12, but
> also have other
> sizes in red. If someone searches for red and size 12, it
> should not bring
> the product as that combination is not possible.
I'm no expert, but one way to do this would be to have a multi-valued field
with all the possible combinations, eg if you have the following in your data:
<color>
<value>red</value>
<sizes>10,12</sizes>
</color>
<color>
<value>black</value>
<sizes>8,10</sizes>
</color>
you could create a solr doc with a mulitvalued "color" field:
<color>color_red size_10 size_12</color>
<color>color_black size_8 size_10</color>
Then if you set the "positionIncrementGap" in your schema to a sufficiently
high value (say 1000), you can use the following query to search for a color
size combination:
color:"color_red size_10"~1000
which executes a phrase search with a slop factor of 1000, ensuring it won't
cross the field boundary
hope this helps!
-Ken