# AspireMeilisearchExtensions Methods

- Package: [CommunityToolkit.Aspire.Meilisearch](/reference/api/csharp/communitytoolkit.aspire.meilisearch.md)
- Type: [AspireMeilisearchExtensions](/reference/api/csharp/communitytoolkit.aspire.meilisearch/aspiremeilisearchextensions.md)
- Kind: `Methods`
- Members: `2`

Provides extension methods for registering Meilisearch-related services in an `Hosting.IHostApplicationBuilder`.

## AddKeyedMeilisearchClient(IHostApplicationBuilder, string, Action<MeilisearchClientSettings>)

- Name: `AddKeyedMeilisearchClient(IHostApplicationBuilder, string, Action<MeilisearchClientSettings>)`
- Modifiers: `extension`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/d9dc6fc02412d7398c5722840513d99965a6e98f/src/CommunityToolkit.Aspire.Meilisearch/AspireMeilisearchExtensions.cs#L51-L54)

Registers `MeilisearchClient` as a keyed singleton for the given `name` in the services provided by the `builder`.

```csharp
public static class AspireMeilisearchExtensions
{
    public static void AddKeyedMeilisearchClient(
        this IHostApplicationBuilder builder,
        string name,
        Action<MeilisearchClientSettings>? configureSettings = null)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IHostApplicationBuilder`)
  The `Hosting.IHostApplicationBuilder` to read config from and add services to.
- `name` (`string`)
  The connection name to use to find a connection string.
- `configureSettings` (`Action<MeilisearchClientSettings>`) `optional`
  An optional method that can be used for customizing the [MeilisearchClientSettings](/reference/api/csharp/communitytoolkit.aspire.meilisearch/meilisearchclientsettings.md). It's invoked after the settings are read from the configuration.

## Exceptions

- `InvalidOperationException` -- If required ConnectionString is not provided in configuration section

## Remarks

Reads the configuration from "Aspire:Meilisearch:Client" section.

## AddMeilisearchClient(IHostApplicationBuilder, string, Action<MeilisearchClientSettings>)

- Name: `AddMeilisearchClient(IHostApplicationBuilder, string, Action<MeilisearchClientSettings>)`
- Modifiers: `extension`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/d9dc6fc02412d7398c5722840513d99965a6e98f/src/CommunityToolkit.Aspire.Meilisearch/AspireMeilisearchExtensions.cs#L33-L36)

Registers `MeilisearchClient` as a singleton in the services provided by the `builder`.

```csharp
public static class AspireMeilisearchExtensions
{
    public static void AddMeilisearchClient(
        this IHostApplicationBuilder builder,
        string connectionName,
        Action<MeilisearchClientSettings>? configureSettings = null)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IHostApplicationBuilder`)
  The `Hosting.IHostApplicationBuilder` to read config from and add services to.
- `connectionName` (`string`)
  The connection name to use to find a connection string.
- `configureSettings` (`Action<MeilisearchClientSettings>`) `optional`
  An optional method that can be used for customizing the [MeilisearchClientSettings](/reference/api/csharp/communitytoolkit.aspire.meilisearch/meilisearchclientsettings.md). It's invoked after the settings are read from the configuration.

## Exceptions

- `InvalidOperationException` -- If required ConnectionString is not provided in configuration section

## Remarks

Reads the configuration from "Aspire:Meilisearch:Client" section.
