---
title: Creating custom smart search analyzers
related:
  - https://docs.kentico.com/13/configuring-xperience/setting-up-search-on-your-website/using-locally-stored-search-indexes/creating-local-search-indexes.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).

If the selection of built‑in indexing analyzers is insufficient, you can specify custom‑written or third‑party analyzers for search indexes. Custom analyzers allow you to perform text tokenization according to any requirements. You can use custom analyzers with any type of smart search index.

To use a custom analyzer, you need to create and add the appropriate code files to your web project. Classes defining custom analyzers must:

- Inherit from the **Lucene.Net.Analysis.Analyzer** class
- Implement the **CMS.Search.ISearchAnalyzer** interface

You also need to deploy your custom analyzer assembly to the separate MVC application to ensure that the analyzer is accessible for indexing operations and searches that occur on the live site.

## Example

The following example demonstrates how to assign a custom analyzer to a smart search index. The sample analyzer divides text into tokens at non-letter characters and is case insensitive.

### Adding the custom analyzer project

1. Open your Xperience solution in Visual Studio.
2. Add a new **Class Library**  project to the solution, for example named _CustomSearchAnalyzer_.
3. Add the Xperience API libraries to the project:
   1. Right-click the solution in the **Solution Explorer** and select **Manage NuGet Packages for Solution**.
   2. Select the **Kentico.Xperience.Libraries** package.
   3. Install the package into the project (the version must match your MVC project's _Kentico.Xperience.AspNet.Mvc5_ package and the exact hotfix version of your Xperience administration project).
4. Reference the _CustomSearchAnalyzer_  project from the Xperience administration project (_CMSApp_).
5. Open your Xperience program files directory (by default _C:\Program Files\Kentico\\_) and expand the _CodeSamples\CustomizationSamples\CustomSearchAnalyzer_ subfolder.
6. Copy the following files into the _CustomSearchAnalyzer_ directory in your web project:
   - **CustomSearchAnalyzer.cs**
   - **SpaceTokenizer.cs**
7. Include the new files into the _CustomSearchAnalyzer_ project in Visual Studio:
   1. Expand the _CustomSearchAnalyzer_ project in the Solution Explorer.
   2. Click **Show all files** at the top of the Solution Explorer.
   3. Select the new files while holding the **Ctrl** key.
   4. Right-click one of the files and select **Include in Project**.
8. Rebuild the solution.

### Assigning the custom analyzer to a search index

1. Sign in to the Xperience administration interface and open the **Smart search** application.
2. Open the **Local indexes** tab.
3. Click **New Index**. Fill in the following properties:

   - **Display name**: Space analyzer page index
   - **Index type**: Pages
   - **Analyzer type**: Custom
   - **Analyzer class - Assembly name**: CustomSearchAnalyzer
   - **Analyzer class - Class**: CMS.CustomSearchAnalyzer.CustomSearchAnalyzer
4. Click **Save**.
5. Switch to the **Indexed content** tab and click **Add allowed content**.
6. Type _/%_ into the **Path** field to index all pages and click **Save**.
7. Switch over to the **Cultures** tab and add the cultures used by your website.
8. Go to the **General** tab and **Rebuild** the index.

You can test the index and its analyzer by switching to the **Search preview** tab and searching for words from the content of the website's pages.
