You can use the following default transformations to display search results using the Smart search dialog with results and Smart search results web parts:
The system returns search results in a search dataset. No matter how the fields are named in the found objects, the search dataset always contains the following fields that are automatically mapped to the corresponding object fields:
|Search result field||Description|
Expresses the relevance of the search result item as a numeric value. Higher values indicate higher relevance.
Mapped to the field selected as the Title field on the Search fields tab for the given object type.
Mapped to the field selected as the Content field on the Search fields tab for the given object type.
Mapped to the field selected as the Date field on the Search fields tab for the given object type.
Mapped to the field selected as the Image field on the Search fields tab for the given object type.
|index||The code name of the search index where the given result was found.|
Available for document search results. The imageClass field contains the name of the CSS class that defines the font icon representing the MIME type of the given document. The system generates the class based on the URL extension of the document (automatic for CMS.File documents).
For example, you can display the MIME type font icon in your search results using the following transformation code:
In the code of ASCX transformations, you can get the values from the dataset by using the Eval("<field name>") function: Eval("score"), Eval("title"), etc.
You can also use the following methods in your transformations:
|Method||Parameters||Description and examples|
Returns the URL of the page containing the details of the search result. The optional parameter indicates if the returned URL is absolute.
<%# SearchResultUrl(true) %>
Note: The SearchResultUrl method does not return valid URLs for search results produced by general indexes, since the indexed objects are not pages and there is no default page to display the object details. You need to write and use a custom transformation method to generate the correct URL of a custom page displaying the appropriate information.
Wraps the text of the first parameter into the tags specified by the other two parameters.
Returns the URL of the current search result's image.
The first parameter specifies the URL used if no image is found – enter either the full relative path starting from the application root (~/), or a partial path starting from the ~/App_Themes/<skin_folder>/Images/ directory. The second parameter specifies the maximum side size to which the method resizes the image.
<%# GetSearchImageUrl("~/App_Themes/Default/Images/CMSModules/CMS_SmartSearch/no_image.gif", 90) %>
<%# GetSearchImageUrl("/CMSModules/CMS_SmartSearch/no_image.gif", 90) %>
Returns the value of the specified field for the current search result. Allows you to access both the general fields of the given objects type (page, custom table etc.) and any other fields included in the search index.
<%# GetSearchValue("DocumentName") %>
|GetSearchedContent||Parses the searched content as XML if required, and removes dynamic controls and macro expressions.|