# Semantic Search

The Semantic Search add-on (`Umbraco.AI.Search`) adds AI-powered vector search to Umbraco. Content is indexed as vector embeddings, and similarity search is available through the CMS Search API and an AI agent tool.

## Installation

{% code title="Package Manager Console" %}

```powershell
Install-Package Umbraco.AI.Search
```

{% endcode %}

Or via .NET CLI:

{% code title="Terminal" %}

```bash
dotnet add package Umbraco.AI.Search
```

{% endcode %}

{% hint style="info" %}
Requires `Umbraco.AI` with an embedding-capable provider such as `Umbraco.AI.OpenAI`.
{% endhint %}

## How it works

1. When content is published, the indexer extracts text from all fields.
2. Text is split into chunks and converted to vector embeddings.
3. Embeddings are stored in the database alongside the content.
4. Searches embed the query and find content with similar vectors.

The index appears alongside other Umbraco indexes as `UmbAI_Search` and supports both content and media.

## Features

* **Semantic search** - Find content by meaning, not keywords
* **Culture-aware** - Separate embeddings per language variant
* **CMS Search integration** - Works with the standard Search API
* **Agent tool** - `semantic_search` tool for AI agent chat
* **SQL Server 2025 support** - Native `VECTOR_DISTANCE()` when available, brute-force fallback on older versions
* **SQLite support** - In-memory similarity for local development
* **Custom vector store** - Replace `IAIVectorStore` to use external providers

## Configuration

Add options under `Umbraco:AI:Search` in `appsettings.json`:

{% code title="appsettings.json" %}

```json
{
  "Umbraco": {
    "AI": {
      "Search": {
        "ChunkSize": 512,
        "ChunkOverlap": 50,
        "DefaultTopK": 100,
        "MinScore": 0.3
      }
    }
  }
}
```

{% endcode %}

| Option         | Default | Description                                                              |
| -------------- | ------- | ------------------------------------------------------------------------ |
| `ChunkSize`    | `512`   | Maximum tokens per text chunk                                            |
| `ChunkOverlap` | `50`    | Token overlap between consecutive chunks                                 |
| `DefaultTopK`  | `100`   | Maximum candidates from vector search before deduplication               |
| `MinScore`     | `0.3`   | Minimum cosine similarity (0.0–1.0) required for a result to be returned |

### Separate database

To store vectors in a separate database, add an `umbracoAIDbDSN` connection string:

{% code title="appsettings.json" %}

```json
{
  "ConnectionStrings": {
    "umbracoAIDbDSN": "Server=ai-db;Database=UmbracoAI;...",
    "umbracoAIDbDSN_ProviderName": "Microsoft.Data.SqlClient"
  }
}
```

{% endcode %}

If omitted, the default `umbracoDbDSN` connection is used.

## Documentation

| Section                                                                     | Description                  |
| --------------------------------------------------------------------------- | ---------------------------- |
| [Concepts](/ai-in-umbraco/add-ons/search/concepts.md)                       | How indexing and search work |
| [Custom vector store](/ai-in-umbraco/add-ons/search/custom-vector-store.md) | Replace the built-in store   |

## Related

* [Add-ons Overview](/ai-in-umbraco/add-ons/add-ons.md) - All add-on packages
* [Embeddings](/ai-in-umbraco/using-the-api/embeddings.md) - Embedding API
* [Providers](/ai-in-umbraco/providers/providers.md) - AI provider configuration


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.umbraco.com/ai-in-umbraco/add-ons/search.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
