This is the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

Vector component specs

The supported vector components that interface with Dapr

Table headers to note:

HeaderDescriptionExample
StatusComponent certification statusAlpha
Beta
Stable
Component versionThe version of the componentv1
Since runtime versionThe version of the Dapr runtime when the component status was set or updated1.11

Generic

ComponentStatusComponent versionSince runtime version
In-memoryAlphav11.19
MeilisearchAlphav11.19

1 - In-memory

Detailed information on the in-memory vector component

The in-memory vector store keeps every collection in the memory of the Dapr sidecar. Use it for local development and tests that need no external vector database. It is not durable: collections and records are lost when the sidecar stops, and they aren’t shared between sidecar instances.

Component format

To set up an in-memory vector store, create a component of type vector.in-memory. 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.in-memory
  version: v1
  metadata:
  - name: indexingDelay
    value: "0s"

Spec metadata fields

FieldRequiredDetailsExample
indexingDelayNQueues every write and applies it once this delay has passed, so that you can test queued acknowledgements and wait timeouts. Defaults to "0s", which applies writes before the call returns."2s"

Supported features

FeatureSupportedDetails
Dense vectorsY
Distance metricsCosine, dot product, EuclideanDISTANCE_METRIC_UNSPECIFIED selects cosine when a collection is created. A query can use a different metric from the collection’s.
Query by IDYA byId that matches no record fails that query with NOT_FOUND.
Score thresholdY
Metadata filteringY
Batch queryYEach query is evaluated independently.
Queued acknowledgementYWrites return INDEX_ACK_QUEUED when indexingDelay is set, so INDEXING_WAIT_TIMEOUT_ACTION_CONTINUE_ASYNC is supported. Without a delay, writes return INDEX_ACK_COMPLETED.
Wait for completionYWith indexingDelay set, the request waits for the queued write, up to waitTimeout.

Queries and records

  • A query compares the query vector with every record in the collection, so query time grows with the number of records.
  • A record whose number of values differs from the collection’s dimensions, or whose values aren’t finite numbers, is reported in failedItems with INVALID_ARGUMENT. Under cosine similarity, a vector whose values are all zero is also rejected. The rest of the records are still written.
  • When topK isn’t set, the component returns up to 10 matches.

2 - Meilisearch

Detailed information on the Meilisearch vector component

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"

Spec metadata fields

FieldRequiredDetailsExample
hostYThe Meilisearch host URL."http://localhost:7700"
apiKeyNThe Meilisearch API key. Required when the Meilisearch instance is protected with a master key. Defaults to ""."masterKey"
timeoutNThe HTTP client timeout for requests to Meilisearch, as a Go duration."10s"

Supported features

FeatureSupportedDetails
Dense vectorsYVectors are stored as user-provided embeddings.
Distance metricsCosine onlySee distance metric and scores.
Query by IDYbyId queries use Meilisearch’s similar documents search. A byId that matches no record fails that query with NOT_FOUND.
Score thresholdY
Metadata filteringY$regex isn’t supported.
Batch queryYEach query is evaluated independently.
Queued acknowledgementYWrites return INDEX_ACK_QUEUED when Meilisearch enqueues the task, so INDEXING_WAIT_TIMEOUT_ACTION_CONTINUE_ASYNC is supported.
Wait for completionYSee 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:

MetadataDetailsExample
filterableAttributesAdditional Meilisearch attributes to declare as filterable. daprMetadata is always filterable."daprMetadata.year"
sortableAttributesMeilisearch 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 id is the Meilisearch primary key. It must be 1 to 511 bytes of ASCII letters, digits, hyphens, and underscores.
  • The record values are stored in _vectors.default.
  • The record metadata is stored as the daprMetadata object. Filter paths are translated to daprMetadata.<path>, so a filter on dealer.city addresses daprMetadata.dealer.city.
  • The record payload is stored base64-encoded under the daprPayload attribute.

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.