Currently, I am trying to implement salary range facets like

10000-20000  (2)
20001-30000  (100)
50000-60000  (150)  

However in Sitecore, we have two different fields (MinSalary & MaxSalary) to store the salary values and I have to use both the fields for the above implementation, for example for the range (10000-20000), minsalary should be considered (10000) for left side value and maxSalary should be considered (20000) for right side value. Is it possible to use two different fields for single range faceting in Solr? any suggestion here.


1 Answer 1


This can be done by creating computed index fields.

To create a computed index field:

  1. Create a class that implements the Sitecore.ContentSearch.ComputedFields.IComputedIndexField interface.

  2. Implement simple string properties named FieldName and ReturnType. The FieldName string is the name the field uses in the index.

  3. Implement a method called ComputeFieldValue(). This method accepts an argument that implements the Sitecore.ContentSearch.IIndexable interface and that specifies the data to index. It returns an object that represents the value for the field.

Your class will look like this example:

public class MinSalary : IComputedIndexField
    public object ComputeFieldValue(IIndexable indexable)
        Item item = (Item) (indexable as SitecoreIndexableItem);
        // your logic

    public string FieldName { get; set; }

    public string ReturnType { get; set; }
  1. Add the computed field to the configuration.

Add the field in AddComputedIndexField section in search config.

<fields hint="raw:AddComputedIndexField">
  <field fieldName="MinSalary" returnType="string">

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.