Share This
All Posts  /  Kentico Development Tips  /  March 28, 2017 

Learn how to display custom data in Kentico smart search results

In this post I will show you how to add custom data into the smart search index and display that custom field as the search result details. Its a relatively quick change to make if you have access to the files on the server. 

First, follow the instructions provided in Kentico's documentation Customizing the content of search indexes under the example "Adding data from a user field to page indexes"

Then, replace the code block under if(indexedPage != null) as follows:

if (indexedPage != null)
    string customdetails = "My custom details"; //Run logic to get the proper custom details
    e.SearchDocument.AddGeneralField("CustomDetails", description, true, false);

Once that is complete you will need to rebuild your index.

Finally, use the transformation method in your search results transformation to get the value.

<%# GetSearchValue("CustomDetails") %>

Keep in mind that this transformation method can get any field already associated with the document, so if you want to just replace the provided description with the meta description, use

<%# GetSearchValue("DocumentPageDescription") %>

To learn more about Kentico's search result transformations, check out the search result transformation documentation

Show More
Share This
Blog post currently doesn't have any comments.
 Security code
Social Buzz

Get in Touch


t: 973.539.5255


715 Main Street
Boonton, NJ 07005


New Jersey

Send Us a Message

 Security code