November Happy Hour will be moved to Thursday December 5th.

Get Content Type from Search Result

Vote:
 

Episerver version 11.12

Using FIND search

I have a requirement where the client wants to display a different icon depending on the "type" of item that gets returned in the search results.  I have a couple of unique page types as well as different media types (PDF, word, excel, etc.)  In the searchResultObject, I see a content GUID, but don't know how to find the content type using only that.  Can someone help with a way to do this?

#209123
Edited, Nov 07, 2019 19:26
Vote:
 

Like this?

var result = SearchClient.Instance.Search<PageData>()
               .FilterForVisitor()
               .OrderByDescending(x => x.StartPublish)
               .GetContentResult();

var ContentTypeNameOfFirstReturnedPage = result.Items.First().ContentTypeName();
#209128
Nov 07, 2019 21:44
* 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.