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 -
--Select--
2010
2011
2012
2013
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?