Another way of doing this would be to create a computed field.
public class MyIdeasMultiValued: AbstractComputedIndexField
{
public override object ComputeFieldValue(IIndexable indexable)
{
Item currentItem = indexable as SitecoreIndexableItem;
List<string> result = new List<string>();
if (currentItem.Fields["My Ideas"].HasValue)
{
var myIdeas = currentItem.Fields["My Ideas"].Value;
var listOfVal = myIdeas.Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries).ToList();
return listOfVal;
}
}
}
Now you will have to tell sitecore to take your new computed field when building the index.
You will need to patch the Sitecore.ContentSearch.Solr.DefaultIndexConfiguration.
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<contentSearch>
<!-- Configuration sections for indexes -->
<indexConfigurations>
<sandboxIndexConfiguration ref="contentSearch/indexConfigurations/defaultSolrIndexConfiguration">
<indexAllFields>false</indexAllFields>
<initializeOnAdd>false</initializeOnAdd>
<documentOptions
type="Sitecore.ContentSearch.SolrProvider.SolrDocumentBuilderOptions, Sitecore.ContentSearch.SolrProvider">
<fields hint="raw:AddComputedIndexField">
<field fieldName="MyIdeasMultiValued" >Test.ComputedFields.MyIdeasMultiValued,Test</field>
</fields>
</documentOptions>
<fieldMap ref="contentSearch/indexConfigurations/defaultSolrIndexConfiguration/fieldMap">
<typeMatches hint="raw:AddTypeMatch">
</typeMatches>
<fieldNames hint="raw:AddFieldByFieldName">
<field fieldName="MyIdeasMultiValued" returnType="stringCollection"></field>
</fieldNames>
</fieldMap>
</sandboxIndexConfiguration>
</indexConfigurations>
</contentSearch>
In the MySearchResultItem
you will add
[IndexField("MyIdeasMultiValued")]
public List<string> MyIdeas { get; set; }
After you rebuild your index you can use the below code to perform the query to check the values.
using (var context = this.GetSearchIndex((Context.ContentDatabase ?? Context.Database).Name).CreateSearchContext())
{
var listOfVal = context.GetQueryable<MySearchResultItem> ().Select(i=>i.MyIdeas);
}
<fieldType fieldName="my_ideas" returnType="stringCollection" />