EPiFind - Error setting value to 'Category'




I have a very simple page type. This is the code that uses EPiFind:

var result = SearchClient.Instance.Search().GetResult();

That code gives me the following exception:

JsonSerializationException was unhandled by user code

An exception of type 'Newtonsoft.Json.JsonSerializationException' occurred in Newtonsoft.Json.dll but was not handled in user code

Additional informtaion: Error setting value to 'Category' on 'MyPageType'

Inner exception: "Property 'PageCategory' does not exist, can only assign values to existing properties"

Everything works fine when if I replace GetResult() with GetPagesResult()

Should I always use GetResult() for custom objects, and GetPagesResult() for episerver page objects, or am I missing something?


Sep 28, 2015 15:49

from an old post, hope that will answer.


When searching with the general .NET API search queries are usually executed using a method named GetResult which returns, among other things, matching objects or projections from matching objects by de-serializing them from JSON. However, when executing a query for EPiServer pages and files stored in VPP folder we often want the returned objects to be the EPiServer objects, such as PageData objects, returned from the EPiServer APIs and not objects deserialized from the index. 

GetContentResult and GetFilesResult both return instances of a type which contain the matching objects, such as matching content objects. These types are ContentResult and FilesResult. This is accomplished by fetching the matching objects IDs from the search engine and then fetching the actual objects from the CMS' API. 
GetPagesResult return instances of a type which contain the matching objects, such as matching PageData objects. Types is PagesResult. 
GetResult: For scenarios where we don't want the whole IContent or UnifiedFile objects but rather a subset of their content, perhaps with highlighting we can instead use the regular GetResult method.


Sep 28, 2015 18:10

Thank you!

Sep 28, 2015 19:31
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.