I have a field in Sitecore that contains data such as "2010,2011,2012,2013" or "Europe;Asia;Africa;Artic" etc. These are string fields and don't need to be anymore than strings. These fields come from an external system. I would like to use them as filters on a listing page that I am creating. I would like to store them as computed fields in a Solr index. After I display them on the page they should look like this in a drop down -


My computed field looks something like this in the index configuration file -

<field fieldName="year" storageType="yes" returnType="stringCollection" indexType="untokenized">Class, Library</field>

I have some code which basically uses splits up the string into a List of a string to pass the value in to the computed field.

When I read it from the Solr index, I do not always get all the values back and it only gives me back a few values. After a rebuild the values change again and I may only get 3 out of 4 values; another time I may only get 1 or 2 after an index rebuild.

The code I'm using to read the field looks something like -

items.Select(x => x.Document.Year).Distinct(StringComparer.CurrentCultureIgnoreCase).OrderBy(x => x).ToList();

Am I doing this correct? Should I be using some other returnType or object type in my configuration?

  • If the values "2010,2011,2012,2013" in a field already, why do you need to use SOLR? Can you just use that field as a datasource for the drop down field? Or is this drop down an html select input?
    – Chris Auer
    Commented Mar 22, 2017 at 5:36
  • 1
    @Gabbar maybe this can help you skillcore.net/sitecore/…
    – Marek Musielak
    Commented Mar 22, 2017 at 7:45
  • @dnstommy .. I have thousands of records and they all have different sets of '2011, 2013' or '2009, 2011,2012' etc. I just want them to be stored in the index so that I can read them directly from the index.
    – Gabbar
    Commented Mar 22, 2017 at 13:21
  • Do you want just the set that is in the field of the current item or all the possible sets in the index for all items?
    – Chris Auer
    Commented Mar 22, 2017 at 13:24
  • 1
    Will give it a try later this week.
    – Gabbar
    Commented Mar 22, 2017 at 17:42

1 Answer 1


it sounds like you would like to do a facet facets = context.GetQueryable()
.FacetOn(x => x.Year) .GetFacets();

the facets is a collection of collections with facet categories (the field YEAR) and inside a collection of facet values (2001, 2002 etc). this is distinct by nature and does not require you to get ANY documents from the index

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.