Smart Search results: Display DocumentName instead of title for a search result

Shweta S asked on November 12, 2019 00:02

Hi,

In smart search transformation I want to display DocumentName when a search result displays results from PageType News. Is there a way to have a if else condition to display either title or document name based on a page type?

Another issues: When smart search displays results from a News pagetype item, it links to the detail page of the news items which does not have any relevant information (it inherits from parent). Is there a way the link displayed in Search result be one of the fields on the News page type (like an external url field)?

Any help will be appreciated.

Thanks

Correct Answer

Mike Wills answered on November 12, 2019 02:31

Hi Shweta,

First we need to ensure that the DocumentName field is not already mapped to the Title field of the index. The easiest way to do that is to map a different field to the search title field in the page type's "Search fields" tab, like this:

Set Title to something else

Then in the search transformation, you can check the page type. If using an ASCX transformation, it would look something like below, in which Title is used for "dancinggoat.article" page types and DocumentName is used for everything else.

<%# IfCompare(GetSearchValue("ClassName"), "dancinggoat.article",  GetSearchValue("DocumentName"), Eval("Title"))%>

If you have more complex logic, it might be easier to use a Text/XML transformation, so you can use macro syntax.

Mike

1 votesVote for this answer Unmark Correct answer

Recent Answers


Mike Wills answered on November 12, 2019 22:15

Thank you Shweta.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.