Gå til indhold

Get started with the Meilisearch integrations

Dette indhold er ikke tilgængeligt i dit sprog endnu.

⭐ 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 — Tilføj CommunityToolkit.Aspire.Hosting.Meilisearch-pakke
aspire add communitytoolkit-meilisearch

Aspire CLI er interaktiv; vælg det passende søgeresultat når du bliver spurgt:

Aspire CLI — Eksempel output
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.