AI OnAI Off
You could retrieve the the original object when listing results.
If you do GetContentResult it's already in the cache.
If it's a page you could can do something like this:
public static PageReference PageLink(this UnifiedSearchHit hit)
{
if (typeof(PageData).IsAssignableFrom(hit.OriginalObjectType))
{
PageReference pageReference = PageReference.ParseUrl(hit.Url);
if (!PageReference.IsNullOrEmpty(pageReference))
{
return pageReference;
}
object internalObject;
if (Global.UrlRewriteProvider.ConvertToInternal(new UrlBuilder(hit.Url), out internalObject))
{
pageReference = internalObject as PageReference;
if (!PageReference.IsNullOrEmpty(pageReference))
{
return pageReference;
}
}
}
return PageReference.EmptyReference;
}
Or just call the OriginalObjectGetter:
public static T GetOriginalObject<T>(this UnifiedSearchHit hit)
{
if (hit.OriginalObjectGetter != null)
{
var original = hit.OriginalObjectGetter.Invoke();
if (original is T)
{
return (T)original;
}
}
return default(T);
}
Then you can:
var content = hit.GetOriginalObject<YourPageDataPage>();
Hi,
I am trying to show a custom field in a unified search results. I can successfully add custom fields to the index based on extension methods:
I can filter on the custom field:
... but what I can't work out how to do, is return the result of the extension method into my results. NB: I've run out of ISearchContent fields to override / project into (primarily because we have different types of searches on the site, which require different implementations of the same field to be displayed in the results, e.g. different excerpt/summary text). I don't really understand the CustomizeProjection method which I suspect may be the answer?
I guess worst case I can use specific elements in the SearchAuthors field for different purposes, but it seems a horrible hack.
NB: I found Per's comments in this article useful to get so far
http://world.episerver.com/Modules/Forum/Pages/Thread.aspx?id=79729