# Azure search services

## Overview

By default, in Sitefinity CMS search indexes are generated and stored locally using [Lucene.NET](http://lucenenet.apache.org/) search library. If your project resides on a cloud storage, you can use alternative search index generation and storage on external services - such as Azure AI Search or an external Elasticsearch server, which are supported alternatives.

## Set up Azure AI Search

To communicate with Azure AI Search, Sitefinity CMS uses [Azure.Search.Documents 11.4.0](https://www.nuget.org/packages/Azure.Search.Documents/11.4.0).

> info **NOTE**: If your project is on version Sitefinity CMS 15.4.8632 or later, you must use the compatible version [Azure.Search.Documents 12.0.0](https://www.nuget.org/packages/Azure.Search.Documents/12.0.0). Note that using a different version of `Azure.Search.Documents` may result in compatibility issues.

To use Azure AI Search for Sitefinity CMS search indexes, perform the following:

1. Follow  [Azure AI Search documentation](https://learn.microsoft.com/en-us/azure/search/) to create an instance of Azure AI Search in the Azure Portal.
2. Obtain the *Service name* and *Admin API key*.
3. In Sitefinity CMS backend, navigate to *Administration » Settings* and click *Search*.
4. Under *Which search service to use in your site?,* select *Azure Search*.
5. In *Search service name*, enter your Azure AI Search service name.

   > info  **NOTE**: You enter only the name of the search service and not the full URL. For example, if the URL is *[https://test.search.windows.net](https://test.search.windows.net/)*, you must enter only `test` as the search service name.
6. In *Admin API key*, enter the API key for your Azure AI Search service.
7. To test Sitefinity's connection with your Azure AI Search service, click *Test connection*.
8. Click *Save changes*.

> info  **NOTE**: Search results are ordered based on `@score` parameter. This method returns the relevance of the result for each search term. By using `@score` parameter, the most relevant results come first. 

For more information, see [Azure AI Search libraries for .NET](https://learn.microsoft.com/en-us/dotnet/api/overview/azure/search?view=azure-dotnet).

## Search index fields and supported data types

When you add a search index to Azure AI Search, Sitefinity CMS creates by default the following fields:

* `Content`
* `ContentType`
* `Id`
* `IdentityField`
* `Language`
* `LastModified`
* `Link`
* `OriginalItemId`
* `PipeId`
* `Provider`
* `PublicationDate`
* `Summary`
* `Title`

> important **IMPORTANT**: Do not add any of these fields as *Additional fields for indexing*, because you will get a duplicate field exception and will not be able to index.
> You must specify the type of the additional fields for indexing according to the data type mapping provided in the following table.
>
> <table>
> <tbody>
> <tr>
> <td>
> <strong>Azure Search data type</strong>
> </td>
> <td>
> <strong>Sitefinity type</strong>
> </td>
> </tr>
> <tr>
> <td>
> Edm.String
> </td>
> <td>
> Short text<br>
> Long text
> </td>
> </tr>
> <tr>
> <td>
> Edm.DateTimeOffset
> </td>
> <td>
> Date and time
> </td>
> </tr>
> <tr>
> <td>
> Edm.Int32
> </td>
> <td>
> Numeric whole number (NumberWhole)
> </td>
> </tr>
> <tr>
> <td>
> Edm.Double
> </td>
> <td>
> Numeric decimal number (NumberDecimal)
> </td>
> </tr>
> <tr>
> <td>
> Edm.Boolean
> </td>
> <td>
> Yes / No
> </td>
> </tr>
> <tr>
> <td>Collection(
> Edm.String
> )</td>
> <td>
> Classification<br>
> Choices
> </td>
> </tr>
> </tbody>
> </table>

## Scoring profiles

Scoring profiles in Azure AI Search allow you to configure the way search results are ranked, based on one or more custom-defined criteria. They are part of the index definition and consist of *weighted* *fields* and *functions*.

Use weighted fields when you want to prioritize search results in a specific field. For instance, prioritize results that are in the *Content* or *Title* fields over other fields.

With functions, you can prioritize results by the time period they were published in, the numeric value of the results, or by tags. Sitefinity CMS supports the following functions:

* `freshness`
* `magnitude`
* `tag`

For the tag function you also need to specify parameters. For more information, see Microsoft documentation » [Add scoring profiles to a search index](https://docs.microsoft.com/en-us/azure/search/index-add-scoring-profiles).

## Create scoring profiles

To create scoring profiles:

1. Set up Sitefinity CMS to use Azure AI Search.
2. Create a search index. For more information, see [Create search indexes](https://www.progress.com/documentation/sitefinity-cms/administration-create-search-indexes).
3. Add scoring profiles in the Azure Portal. For more information, see Microsoft documentation » [Add scoring profiles to a search index](https://docs.microsoft.com/en-us/azure/search/index-add-scoring-profiles).
4. Configure the *Search box* widget by following the procedure:
   * For ASP.NET Core based frontend: [Search box widget](https://www.progress.com/documentation/sitefinity-cms/search-box-widget-net-core) » *Boost search results*
   * For Next.js based frontend: [Search box widget](https://www.progress.com/documentation/sitefinity-cms/next.js-search-box-widget) » *Boost search results*

> important **IMPORTANT**: When you use the Tag scoring function, you must add a Tags parameter in the Azure Portal. When a Tags parameter is added to an index, you can configure these parameters in the Advanced settings of the *Search box* widget.
