Перейти до вмісту

Meilisearch Hosting integration reference

Цей контент ще не доступний вашою мовою.

⭐ Community Toolkit Meilisearch logo

To get started with the Aspire Meilisearch integrations, follow the Get started with Meilisearch integrations guide.

This article includes full details about the Aspire Meilisearch Hosting integration.

To access the hosting integration APIs for expressing Meilisearch resources in your AppHost project, install the 📦 CommunityToolkit.Aspire.Hosting.Meilisearch NuGet package:

Aspire CLI — Додати пакет CommunityToolkit.Aspire.Hosting.Meilisearch
aspire add communitytoolkit-meilisearch

Aspire CLI інтерактивний; оберіть відповідний результат пошуку:

Aspire CLI — Приклад виводу
Select an integration to add:
> communitytoolkit-meilisearch (CommunityToolkit.Aspire.Hosting.Meilisearch)
> Other results listed as selectable options...

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...

The Meilisearch resource includes a randomly generated master key when one wasn’t provided.

To add a data volume to the Meilisearch resource, call the WithDataVolume method:

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

The data volume is used to persist the Meilisearch data outside the lifecycle of its container. The data volume is mounted at the /meili_data path in the Meilisearch container.

Add Meilisearch resource with data bind mount

Section titled “Add Meilisearch resource with data bind mount”

To add a data bind mount to the Meilisearch resource, call the WithDataBindMount method:

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

Data bind mounts rely on the host machine’s filesystem to persist the Meilisearch data across container restarts.

Add Meilisearch resource with master key parameter

Section titled “Add Meilisearch resource with master key parameter”

When you want to explicitly provide the master key used by the container image, you can provide these credentials as parameters:

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