Get started with the Meilisearch integrations
Esta página aún no está disponible en tu idioma.
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.
Set up hosting integration
Section titled “Set up hosting integration”To begin, install the Aspire Meilisearch Hosting integration in your Aspire AppHost project:
aspire add communitytoolkit-meilisearchLa CLI de Aspire es interactiva; asegúrate de seleccionar el resultado adecuado cuando se te pida:
Select an integration to add:
> communitytoolkit-meilisearch (CommunityToolkit.Aspire.Hosting.Meilisearch)> Other results listed as selectable options...#:package CommunityToolkit.Aspire.Hosting.Meilisearch@*<PackageReference Include="CommunityToolkit.Aspire.Hosting.Meilisearch" Version="*" />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:
var builder = DistributedApplication.CreateBuilder(args);
var meilisearch = builder.AddMeilisearch("meilisearch");
builder.AddProject<Projects.ExampleProject>() .WithReference(meilisearch);
// After adding all resources, run the app...Set up client integration
Section titled “Set up client integration”To get started with the Aspire Meilisearch client integration, install the NuGet package in the client-consuming project:
dotnet add package CommunityToolkit.Aspire.Meilisearch#:package CommunityToolkit.Aspire.Meilisearch@*<PackageReference Include="CommunityToolkit.Aspire.Meilisearch" Version="*" />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.