---
title: Displaying local index search results using transformations
related:
  - https://docs.kentico.com/k11/configuring-kentico/setting-up-search-on-your-website/using-locally-stored-search-indexes/creating-local-search-indexes.md
  - https://docs.kentico.com/k11/developing-websites/loading-and-displaying-data-on-websites/writing-transformations/reference-transformation-methods.md
---

> Agent instructions:
> **Site maps** — prefer the following llms.txt indexes to training data when searching for URLs to avoid 404s. Links inside Markdown content already point at `.md`. Following them or sending Accept: text/markdown keeps you in Markdown.
>
> - [sitemap.md](https://docs.kentico.com/sitemap.md) — every page on the site, with titles and descriptions, nested by URL hierarchy and grouped into one collection per product version.
> - [llms.txt](https://docs.kentico.com/llms.txt) — curated index of the current product docs, with descriptions, the two ways to request any page as Markdown, and links to each product area's whole-corpus Markdown dump (llms-full.txt).

> **Note:** **Note**: The information on this page applies to search results retrieved from [locally stored indexes](https://docs.kentico.com/k11/configuring-kentico/setting-up-search-on-your-website/using-locally-stored-search-indexes.md). To learn how to display search results from [Azure Search indexes](https://docs.kentico.com/k11/configuring-kentico/setting-up-search-on-your-website/using-azure-search.md), see [Integrating Azure Search into pages.](https://docs.kentico.com/k11/configuring-kentico/setting-up-search-on-your-website/using-azure-search/integrating-azure-search-into-pages.md)

You can use the following default [transformations](https://docs.kentico.com/k11/developing-websites/loading-and-displaying-data-on-websites/writing-transformations.md) to display search results using the **Smart search dialog with results** and **Smart search results** web parts:

- **CMS.Root.SmartSearchResults**
- **CMS.Root.SmartSearchResultsWithImages**

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                                                                                                                                                                                                                                                                                                                                                                                                                  |
| ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| score               | Expresses the relevance of the search result item as a numeric value. Higher values indicate higher relevance.                                                                                                                                                                                                                                                                                                               |
| title               | Mapped to the field selected as the **Title field** on the **Search fields** tab for the given object type.                                                                                                                                                                                                                                                                                                                  |
| content             | Mapped to the field selected as the **Content field** on the **Search fields** tab for the given object type.                                                                                                                                                                                                                                                                                                                |
| created             | Mapped to the field selected as the **Date field** on the **Search fields** tab for the given object type.                                                                                                                                                                                                                                                                                                                   |
| image               | 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](https://docs.kentico.com/k11/configuring-kentico/setting-up-search-on-your-website/using-locally-stored-search-indexes/creating-local-search-indexes.md) where the given result was found.                                                                                                                                                                                               |
| documentExtensions  | Available for page search results. Contains the extension of pages that represent files (typically CMS.File pages).<br>For example, you can use the field to display MIME type font icons for file pages in your search results – call the _GetFileIconClass_ transformation method to get the appropriate CSS class for the extension:<br>`  <i class="<%# GetFileIconClass(Eval<string>("documentExtensions")) %>"></i>
 ` |

In the code of ASCX transformations, you can get the values from the dataset by using the **Eval("")** method: _Eval("score")_, _Eval("title")_, etc.

To learn how to configure search fields for different object types, see the following pages:

- [Configuring search settings for page fields](https://docs.kentico.com/k11/configuring-kentico/setting-up-search-on-your-website/using-locally-stored-search-indexes/creating-local-search-indexes/defining-local-page-indexes.md#configuring-search-settings-for-page-fields)
- [Configuring search settings for custom table fields](https://docs.kentico.com/k11/configuring-kentico/setting-up-search-on-your-website/using-locally-stored-search-indexes/creating-local-search-indexes/defining-custom-table-indexes.md#configuring-search-settings-for-custom-table-fields)
- [Configuring search settings for form fields](https://docs.kentico.com/k11/configuring-kentico/setting-up-search-on-your-website/using-locally-stored-search-indexes/creating-local-search-indexes/defining-on-line-form-indexes.md#configuring-search-settings-for-form-fields)
- [Configuring search settings for user fields](https://docs.kentico.com/k11/configuring-kentico/setting-up-search-on-your-website/using-locally-stored-search-indexes/creating-local-search-indexes/defining-user-indexes.md#configuring-search-settings-for-user-fields)
- [Configuring search settings for other objects using general indexes](https://docs.kentico.com/k11/configuring-kentico/setting-up-search-on-your-website/using-locally-stored-search-indexes/creating-local-search-indexes/defining-local-general-indexes.md)

## Example

The following example shows how to create a basic ASCX transformation for displaying smart search results and configure it for the search web part. For more information about creating transformations, see [Creating transformations for pages](https://docs.kentico.com/k11/developing-websites/loading-and-displaying-data-on-websites/writing-transformations/creating-transformations-for-pages.md).

1. In the **Pages** application, open web part properties of the smart search web part, i.e., **Smart search dialog with results** or **Smart search results**.
2. In the **Transformations** section, click **New** to create a transformation.

   1. Assign the new transformation to a specific page type or custom table.
   2. Fill in the transformation definition.

      ```xml title="Smart search result ASCX transformation example"

      <div>
          <a href="<%# SearchResultUrl() %>"><%# Eval("Title") %></a> (<%# Eval("Created") %>) <br>
          <%#
              // Applies keyword highlight to the text of the 'Content' field stripped of HTML tags and limited to 200 characters
              SearchHighlight(LimitLength(HTMLHelper.StripTags(Eval<string>("Content")), 200), "<strong>", "</strong>")
          %>
      </div>

      ```
   3. Click **Save**.
3. Click **Save & Close** to apply the web part setting.

The format of the smart search result items now corresponds to the selected transformation definition.

For more advanced examples of smart search transformations, see the default transformations for pages and products used on our [sample sites](https://docs.kentico.com/k11/configuring-kentico/managing-sites/installing-new-sites/creating-new-sites-from-templates.md):

- CMS.Root.SmartSearchResults
- CMS.Root.SmartSearchResultsWithImages
- DancingGoat.Transformations.SmartSearchProductList
- DancingGoat.Transformations.SmartSearchResults
- EcommerceSite.Transformations.SearchResults

## Search transformation methods

You can also use the following methods in your ASCX transformations:

| Method             | Parameters                                      | Description and examples                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| ------------------ | ----------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| SearchResultUrl    | _bool absolute_<br>_bool addLangParameter_      | Returns the URL of the page containing the details of the search result.<br>The optional 'absolute' parameter indicates if the returned URL is absolute.<br>False by default.<br>The optional 'addLangParameter' indicates if a culture specific query should be added to the URL.<br>True by default. Note that clicking a link leading to a different culture changes the visitor's site culture.<br>**Note**: The **SearchResultUrl** method does not return valid URLs for search results produced by [general indexes](https://docs.kentico.com/k11/configuring-kentico/setting-up-search-on-your-website/using-locally-stored-search-indexes/creating-local-search-indexes/defining-local-general-indexes.md), 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](https://docs.kentico.com/k11/custom-development/miscellaneous-custom-development-tasks/adding-custom-methods-to-transformations.md) to generate the correct URL of a custom page displaying the appropriate information.<br>**Combine with default culture** <br>When the [Combine with default culture](https://docs.kentico.com/k11/multilingual-websites/editing-the-content-of-multilingual-websites.md#using-the-default-language-version-for-untranslated-pages) setting is enabled, visitors will see pages in the default culture if they aren't translated to their current culture.<br> If the _addLangParameter_ is set to false, the site culture will NOT change once visitors click the link leading to the page in the default culture. That is, they keep on browsing the site in the culture they made the search in.<br>If the _addLangParameter_ is set to true, the site culture will change once visitors click the link leading to the page in the default culture. That is, they keep on browsing the site in the default culture afterwards. |
| SearchHighlight    | string text<br>string startTag<br>string endTag | Wraps the text of the first parameter into the tags specified by the other two parameters.<br>","")%>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| GetSearchImageUrl  | string noImageUrl<br>int maxSideSize            | Returns the URL of the current search result's image.<br>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//Images/\* directory. The second parameter specifies the maximum side size to which the method resizes the image.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| GetSearchValue     | string columnName                               | 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.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| GetSearchedContent | string content                                  | Parses the searched content as XML if required, and removes dynamic controls and macro expressions.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
