Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Episerver Find - Unable to deserialize IList<string>


I am indexing pages which have a base class with an IList<string> property like below:

public virtual IList<string> TagCodes


   get { return new List<string> { "Shoulder", "Knee", "Video" }; }



It gets indexed correctly and looks as following when I do index view:

"TagCodes": [

However, when I perform the actual search I am getting the following exception "To deserialize objects the $type property must be set.". I am a bit at loss at what is happening and what I am missing.

.Select(p => new SearchResultItem
TagCodes = p.TagCodes
} as ISearchResultItem)

Below is exception stack trace as well:

   at EPiServer.Find.ProjectionHelper.DeserializeObject(JToken root)
   at EPiServer.Find.ProjectionHelper.AddPartialFields(SearchRequestBody requestBody, SearchHit`1 searchHit, Dictionary`2 args)
   at EPiServer.Find.ProjectionHelper.GetFieldValues(SearchRequestBody requestBody, SearchHit`1 searchHit)
   at EPiServer.Find.ProjectionHelper.GetMappedSearchResultItem[TResult](SearchRequestBody requestBody, SearchHit`1 searchHit)
   at EPiServer.Find.ProjectionHelper.GetMappedResult[TResult](SearchRequestBody requestBody, SearchResults`1 jsonResult)
   at EPiServer.Find.SearchExtensions.GetProjectedResult[TResult](ISearch`1 search, SearchContext context)
   at EPiServer.Find.SearchExtensions.GetResult[TResult](ISearch`1 search)
Oct 04, 2013 17:00


What happens if you change the type from an interface to a concrete implementation of list?

IList<string>  ---> List<string>

Oct 04, 2013 19:55

This has helped, thank you very much Johan!

Oct 07, 2013 7:42
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.