---
title: Searching attachment files
related:
  - https://docs.kentico.com/13/configuring-xperience/setting-up-search-on-your-website/searching-attachment-files/adding-custom-search-text-extractors-for-files.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).

The [smart search](https://docs.kentico.com/13/configuring-xperience/setting-up-search-on-your-website.md) allows users to search through the content of files uploaded as [page attachments](https://docs.kentico.com/13/managing-website-content/working-with-files/page-attachments/attaching-files-to-pages.md). The attachment search supports both types of [file storage](https://docs.kentico.com/13/configuring-xperience/managing-files/storing-files.md) provided by Xperience (database or file system).

> **Info:** The attachment search only works for files that are connected to pages through one of the following methods:
>
> - Attachment files added to pages through fields with the **Data type** set to _**File**_ or _**Attachments**_ in the [page type definition](https://docs.kentico.com/13/developing-websites/defining-website-content-structure/managing-page-types/creating-page-types.md)
> - Attachments uploaded in the **Pages** application on the **Properties -> Attachments** tab of pages

## Choosing which file types are searchable

By default, the attachment search supports the following file types:

- txt
- csv
- pdf
- docx
- xlsx
- pptx
- xml
- html
- htm

> **Note:** **Note**: The search does NOT work for:
>
> - Legacy MS Office formats: doc, xls, ppt
> - Certain types of PDF files, including:
>   - Encrypted files
>   - Files using PDF version 1.5 or older

You can limit which of the file types are searchable for individual websites:

1. Open the **Settings** application.
2. Navigate to the **System -> Search** category.
3. Select file extensions in the **Allowed attachment file types** setting (if no checkboxes are selected, all supported types of attachment files are indexed).
4. Click **Save**.

If you wish to search one of the unsupported file types, you need to implement a [custom search text extractor](https://docs.kentico.com/13/configuring-xperience/setting-up-search-on-your-website/searching-attachment-files/adding-custom-search-text-extractors-for-files.md).

## Enabling indexing for page attachments

The attachment search functionality is supported by indexes of the **Pages** type, for both [Azure Search indexes](https://docs.kentico.com/13/configuring-xperience/setting-up-search-on-your-website/using-azure-cognitive-search/creating-azure-search-indexes.md) and [local indexes](https://docs.kentico.com/13/configuring-xperience/setting-up-search-on-your-website/using-locally-stored-search-indexes/creating-local-search-indexes/defining-local-page-indexes.md).

**Requirement**: The attachment search is only available for pages whose page type uses the **Content fields** or **Both** data source for search (configured in the _Page types_ application on the _Search_ tab).

To set up the attachment search for your website:

1. Open the **Smart search** application.
2. Create or edit a search index of the **Pages** type (either as an [Azure Search index](https://docs.kentico.com/13/configuring-xperience/setting-up-search-on-your-website/using-azure-cognitive-search/creating-azure-search-indexes.md) or a [local index](https://docs.kentico.com/13/configuring-xperience/setting-up-search-on-your-website/using-locally-stored-search-indexes/creating-local-search-indexes/defining-local-page-indexes.md)).
3. When defining the search content on the **Indexed content** tab, select the **Include attachment content** option for the index's allowed content.
4. Click **Save**.
5. Switch to the **General** tab and **Rebuild** the index.

While building the page index, the smart search processes the allowed pages, extracts the text of any attachment files and includes it in the content of the index (along with the other page data). When users perform a search using the index, the system returns results for pages whose attachments match the search expression.

> **Note:** **Updating the search content of attachments (Upgrades and Hotfixes)**
>
> Xperience stores the text content extracted from page attachments in the database. When rebuilding page indexes, the search loads the "cached" attachment text from the database. The system only processes the file text directly for attachments that do not have any search content saved.
>
> If you apply a hotfix or upgrade that changes how the search indexes attachment files, you need to clear the attachment search content:
>
> 1. Open the **System** application.
> 2. Select the **Files -> Attachments** tab.
> 3. Click **Clear attachment search cache**.
>
> You can then **Rebuild** your page indexes, which updates the attachment content according to the new functionality.

## Configuring the attachment search

You can adjust how the system indexes attachment files by adding keys to the **appSettings** section of your application's **web.config** file.

> **Info:** The indexed content always includes:
>
> - File metadata (title, tags, author name etc.)
> - Comments (for example in MS Office files)

### Limiting the maximum size of indexed files

Indexing of very large files can be resource intensive and have a negative impact on your website's performance. To prevent the system from indexing files larger than a certain size, add the **CMSSearchMaxAttachmentSize** key:

```html

<add key="CMSSearchMaxAttachmentSize" value="10000" />

```

They key sets the maximum allowed file size in kB. The search ignores page attachments whose size exceeds the value.

### Indexing of XML content

When indexing the content of XML files, the search does NOT include the following content by default:

- Comments
- The values of tag attributes

You can enable indexing for such content by adding the following web.config keys:

```html

<add key="CMSSearchIndexXmlComments" value="true" />
<add key="CMSSearchIndexXmlAttributes" value="true" />

```

### Enabling character encoding detection for text files

By default, the search can read text files (**txt** and **csv**) that use the following character encoding:

- [UTF-8](http://en.wikipedia.org/wiki/Utf-8)
- The default Windows encoding (the operating system's current ANSI code page)

If you encounter problems when indexing text files with a different encoding type, you can enable automatic encoding detection:

```html

<add key="CMSSearchDetectTextEncoding" value="true" />

```

The system then attempts to detect the encoding type for each file, and use the correct option when reading the content during the indexing process.

> **Note:** **Note**: Correct encoding detection is not guaranteed for all files. Automatic detection also slightly increases the time required to index text files.
