I'm working on a Sitecore upgrade from 8.2 to 10.1, which includes replacing Lucene with Solr. I have a content listing page that allows filtering by content type as well as many other fields - these are OOTB Sitecore fields, not computed. I have this SearchResultItem defined:
public class ContentTypeSearchResultItem : Sitecore.ContentSearch.SearchTypes.SearchResultItem
{
[Sitecore.ContentSearch.IndexField("region_sm")]
[TypeConverter(typeof(IndexFieldEnumerableConverter))]
public Guid Region { get; set; }
[Sitecore.ContentSearch.IndexField("content_type_sm")]
[TypeConverter(typeof(IndexFieldEnumerableConverter))]
public IEnumerable<Guid> ContentType { get; set; }
}
One thing I changed initially was that the names had no suffixes, so I changed "content_type"
to "content_type_sm"
(this was after I got the Undefined error the first time)
My fields exist in Solr:
and in fact in another place in the site where I pull all items with a particular template ID, when I inspect the items while debugging, I can drill into the fields and see that they have the "content_type_sm" field and it is properly populated.
But on the listing page, my query which uses this code:
var contentTypePredicate = PredicateBuilder.True<ContentTypeSearchResultItem>();
foreach (var taxonomy in taxonomies)
{
contentTypePredicate = contentTypePredicate.Or(x => x.ContentType.Contains(taxonomy));
}
predicate = predicate.And(contentTypePredicate);
...returns no results and I see the error in my logs, ERROR Solr Error : [undefined field content_type]
EDIT:
Manually updating the fieldMap fixed the issue:
<field fieldName="content_type" returnType="stringCollection"></field>