AI OnAI Off
We have used this approach to getting a "live" PageData object from a UnifiedSearchHit:
GetPageFromHit(UnifiedSearchHit hit)
{
if (typeof(PageData).IsAssignableFrom(hit.OriginalObjectType))
{
object internalObject;
if (Global.UrlRewriteProvider.ConvertToInternal(new EPiServer.UrlBuilder(hit.Url), out internalObject))
{
var pageReference = internalObject as PageReference;
I have a search page from which i want to search indexed objects of types PageData, VersioningFile, BlogItem and PersonWrapper
BlogItem and PersonWrapper are custom objects and I want each search result to look different on the search page. For example: The pagedata results are going to show some basic data such as PageName, MainBody and breadcrumbs and the PersonWrapper result will show a picture of the person and his/hers contact information.
What's the best practice way to do this? At the moment I've been trying to do a unified search but I'm having trouble retrieving the original object from the UnifiedSearchHit.OriginalObjectGetter.Invoke() method since the OriginalObjectGetter property is null.
I read somewhere that this method only works for pagedata objects and versioningfile object and if you use a custom object then you need to project a getter method to the UnifiedSearchRegistrys' ProjectOriginalObjectGetterFrom method. This wouldn't be very good for performance though since I don't have a method to get just one person. I would have to fetch all persons again and find the one i need. I find it abit odd that this is even needed since if you're debugging and checking the base class of the UnifiedSearchHit.Document then you can see the original object but if i simple try to do "UnifiedSearchHit.Document as PersonWrapper" then I get "Cannot convert type 'EPiServer.Find.UnifiedSearch.UnifiedSearchHit' to 'PersonWrapper' via built-in convention"
So that leaves me with doing a normal search over multiple types but then i would have to create a common class and parse the result to this class and that can't really be the prefered way to do it I would guess.
Would really appreachiate some guideance here. I'm new to EPiServer Find...