Pular para o conteúdo

Get started with the Meilisearch integrations

Este conteúdo não está disponível em sua língua ainda.

⭐ Community Toolkit Meilisearch logo

Meilisearch is a fast, open-source search engine that makes search and discovery easy. The Aspire Meilisearch integration enables you to connect to existing Meilisearch instances or create new instances from Aspire using the docker.io/getmeili/meilisearch container image.

In this introduction, you’ll see how to install and use the Aspire Meilisearch integrations in a simple configuration. If you already have this knowledge, see Meilisearch hosting integration for full reference details.

To begin, install the Aspire Meilisearch Hosting integration in your Aspire AppHost project:

Aspire CLI — Adicionar pacote CommunityToolkit.Aspire.Hosting.Meilisearch
aspire add communitytoolkit-meilisearch

A CLI Aspire é interativa; escolhe o resultado apropriado quando solicitado:

Aspire CLI — Exemplo de saída
Select an integration to add:
> communitytoolkit-meilisearch (CommunityToolkit.Aspire.Hosting.Meilisearch)
> Other results listed as selectable options...

Next, in the AppHost project, register and consume the Meilisearch integration using the AddMeilisearch extension method to add the Meilisearch container to the application builder:

C# — AppHost.cs
var builder = DistributedApplication.CreateBuilder(args);
var meilisearch = builder.AddMeilisearch("meilisearch");
builder.AddProject<Projects.ExampleProject>()
.WithReference(meilisearch);
// After adding all resources, run the app...

To get started with the Aspire Meilisearch client integration, install the NuGet package in the client-consuming project:

.NET CLI — Add CommunityToolkit.Aspire.Meilisearch package
dotnet add package CommunityToolkit.Aspire.Meilisearch

In the Program.cs file of your client-consuming project, call the AddMeilisearchClient extension method to register a MeilisearchClient for use via the dependency injection container:

builder.AddMeilisearchClient(connectionName: "meilisearch");

You can then retrieve the MeilisearchClient instance using dependency injection. For example, to retrieve the client from a service:

public class ExampleService(MeilisearchClient client)
{
// Use client...
}

For full reference details, see Meilisearch hosting integration and Meilisearch client integration.