Archive for category SOLR

Faceting on product specifications with SOLR computed fields in Sitecore

In most product repositories, we come across product specification sets for each product, which usually comprise of a key value pair.
2015-09-20_015800
We had one such scenario in our project, and we came across the requirement to facet on various specification keys.

We have currently added a list of comma separated (key, value) pairs in the specifications computed field. The computed field needed to be declared as a string collection:

<field fieldName="productspecificationstext" returnType="stringCollection" storageType="YES" indexType="string">
    mysite.ComputedFields.ProductSpecificationsText,mysite
</field>

And in the code for the computed field (implementing IComputedIndexField), you will want to split this list and return it as a List.
So this

public object ComputeFieldValue(IIndexable indexable)

would return List<string>

Here’s a sample from the index:

2015-09-20_020439

So then we facet on this field, and filter out the facets that start with (specification key + ‘,’) for the specification key we want the facets for and remove the preceding key and ‘,’.
So if I were to facet on size specification for the below data (provided we had a separator between the specification key and value), we would get:

2015-09-20_021329

Large (1)
Small (3)
Medium (1)

This way, we use the same computed field to facet on any kind of specification.

The method used would be the Sitecore.ContentSearch method:

2015-09-20_021622

, , , , , , , ,

Leave a comment