Meilisearch
Component format
To set up a Meilisearch vector store, create a component of type vector.meilisearch. See this guide on how to create and apply a vector store configuration.
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: <NAME>
spec:
type: vector.meilisearch
version: v1
metadata:
- name: host
value: "http://localhost:7700"
- name: apiKey
value: "<API_KEY>"
- name: timeout
value: "10s"
Warning
The above example uses secrets as plain strings. It is recommended to use a secret store for the secrets, as described here.Spec metadata fields
| Field | Required | Details | Example |
|---|---|---|---|
host | Y | The Meilisearch host URL. | "http://localhost:7700" |
apiKey | N | The Meilisearch API key. Required when the Meilisearch instance is protected with a master key. Defaults to "". | "masterKey" |
timeout | N | The HTTP client timeout for requests to Meilisearch, as a Go duration. | "10s" |
Supported features
| Feature | Supported | Details |
|---|---|---|
| Dense vectors | Y | Vectors are stored as user-provided embeddings. |
| Distance metrics | Cosine only | See distance metric and scores. |
| Query by ID | Y | byId queries use Meilisearch’s similar documents search. A byId that matches no record fails that query with NOT_FOUND. |
| Score threshold | Y | |
| Metadata filtering | Y | $regex isn’t supported. |
| Batch query | Y | Each query is evaluated independently. |
| Queued acknowledgement | Y | Writes return INDEX_ACK_QUEUED when Meilisearch enqueues the task, so INDEXING_WAIT_TIMEOUT_ACTION_CONTINUE_ASYNC is supported. |
| Wait for completion | Y | See waiting for writes. |
Collection settings
A collection is a Meilisearch index with a single userProvided embedder named default with the requested dimensions. Record metadata is filterable by default.
You can pass the following Meilisearch index settings as comma-separated values in the metadata of a create collection request:
| Metadata | Details | Example |
|---|---|---|
filterableAttributes | Additional Meilisearch attributes to declare as filterable. daprMetadata is always filterable. | "daprMetadata.year" |
sortableAttributes | Meilisearch attributes to declare as sortable. | "daprMetadata.year" |
Creating a collection that already exists returns ALREADY_EXISTS and doesn’t change its settings. Collections share the Meilisearch instance with search indexes: list collections only returns indexes that have the default user-provided embedder, and getting or deleting any other index as a collection, or upserting or deleting records in it, returns FAILED_PRECONDITION.
Get collection returns the following properties: primaryKey (always id), filterableAttributes, and sortableAttributes when set.
Record mapping
- The record
idis the Meilisearch primary key. It must be 1 to 511 bytes of ASCII letters, digits, hyphens, and underscores. - The record
valuesare stored in_vectors.default. - The record
metadatais stored as thedaprMetadataobject. Filter paths are translated todaprMetadata.<path>, so a filter ondealer.cityaddressesdaprMetadata.dealer.city. - The record
payloadis stored base64-encoded under thedaprPayloadattribute.
Distance metric and scores
Meilisearch only supports cosine similarity for user-provided embeddings. DISTANCE_METRIC_UNSPECIFIED selects cosine, and any other metric in a create collection or query request returns INVALID_ARGUMENT. Because cosine similarity is undefined for a vector whose values are all zero, such vectors, and vectors with values that aren’t finite numbers, are rejected with INVALID_ARGUMENT.
For a vector query, Meilisearch reports a normalised ranking score of (1 + cosine) / 2. The component converts it back so that match scores are the cosine similarity in [-1, 1], and translates a scoreThreshold of t into a Meilisearch rankingScoreThreshold of (1 + t) / 2. A scoreThreshold outside [-1, 1] returns INVALID_ARGUMENT.
When topK isn’t set, the component returns up to 10 matches.
Waiting for writes
Meilisearch processes writes asynchronously as tasks. With INDEXING_MODE_WAIT_FOR_COMPLETION, the component waits for the task to finish by polling the Meilisearch task API with exponential backoff.
When the experimental Meilisearch tasksStreamingRoute feature is enabled and the API key has the tasks.get permission, the component instead shares a single task-change stream for all waiting writes. If the route reports that it is unavailable, the component falls back to polling. The choice is transparent to your application.
A Meilisearch task is atomic: if the task fails, none of the records in it are written, and a request that waits for completion fails with the task’s error. The component therefore checks the records that Meilisearch would reject before it sends the task. A record with an invalid id, no vector values, a number of values that differs from the collection’s dimensions, or a vector with a zero norm or non-finite values is reported in failedItems with INVALID_ARGUMENT, and the rest of the records are still written.
Upserting into a collection that doesn’t exist fails the request with NOT_FOUND.
Setup Meilisearch
Run Meilisearch locally with Docker:
docker run -d --name meilisearch -p 7700:7700 \
-e MEILI_MASTER_KEY=masterKey \
getmeili/meilisearch:v1.43
Set host to http://localhost:7700 and apiKey to masterKey.
For other installation options, see the Meilisearch installation guide.
Create a project in Meilisearch Cloud, then set host to the project URL and apiKey to an API key with the permissions your application needs.