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

Return to the regular view of this page.

Search component specs

The supported search 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 search component

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

Component format

To set up an in-memory search store, create a component of type search.in-memory. See this guide on how to create and apply a search store configuration.

apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
  name: <NAME>
spec:
  type: search.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
Full-text searchYSee scores and total hits.
FilteringY
SortingY
HighlightingNA query with highlightFields returns UNIMPLEMENTED.
PaginationYContinuation tokens are offset based.
Native queriesNA query with native returns UNIMPLEMENTED.
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.

Scores and total hits

  • A full-text query searches the searchFields of the query, or every content field when searchFields isn’t set. Matching is case-insensitive, and text is split into words of letters and digits.
  • A document matches only when every query term occurs in the searched fields. The hit score is the number of times the query terms occur.
  • Without sort, hits are ordered by score, highest first, then by document ID. With sort, the score and document ID break ties.
  • totalHits is exact and reported with TOTAL_HITS_RELATION_EXACT.
  • When topK isn’t set, the component returns up to 10 hits per page.

2 - Meilisearch

Detailed information on the Meilisearch search component

Component format

To set up a Meilisearch search store, create a component of type search.meilisearch. See this guide on how to create and apply a search store configuration.

apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
  name: <NAME>
spec:
  type: search.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
Full-text searchYtext queries use Meilisearch’s keyword search.
FilteringYFilters must only use attributes declared in filterableAttributes. $regex isn’t supported.
SortingYSort fields must be declared in sortableAttributes.
HighlightingYHighlighted fragments use <em> tags.
PaginationYContinuation tokens are offset based.
Native queriesYSee native queries.
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.

Index settings

Pass the following Meilisearch index settings as comma-separated values in the metadata of a create index request:

MetadataDetailsExample
filterableAttributesContent fields that filters can use. Meilisearch rejects filters on fields that aren’t declared here."category,price"
sortableAttributesContent fields that sorts can use. id is always added, because the component uses the document ID as a tie-breaker for stable pagination."price,publishedAt"
searchableAttributesContent fields that full-text queries search, in order of importance. When omitted, all fields are searchable."title,body"

The component also moves the sort ranking rule first, so that a query with sort returns hits in the requested order, with relevance breaking ties.

Settings are only applied when an index is created. Creating an index that already exists returns ALREADY_EXISTS and doesn’t change its settings.

Get index returns the following properties: primaryKey (always id), and filterableAttributes, sortableAttributes, and searchableAttributes when set.

Document mapping

  • The document id is the Meilisearch primary key. It must be 1 to 511 bytes of ASCII letters, digits, hyphens, and underscores.
  • The keys of the document content are stored as top-level Meilisearch attributes. id, daprMetadata, daprPayload, and keys starting with _ are reserved by the component and can’t be used in content.
  • The document metadata is stored under the reserved daprMetadata attribute and returned unchanged. A full-text query never searches it.
  • A document with an invalid id, or whose content uses a reserved key, is reported in failedItems with INVALID_ARGUMENT and isn’t sent to Meilisearch. The rest of the batch is still indexed.
  • Indexing documents into an index that doesn’t exist fails the request with NOT_FOUND, instead of letting Meilisearch create an index without the component’s settings.

Scores and total hits

  • Hit scores are Meilisearch’s ranking score, a value between 0 and 1 where higher is more relevant.
  • totalHits is Meilisearch’s estimated total number of hits, reported with TOTAL_HITS_RELATION_ESTIMATE. When the total reaches the index’s maxTotalHits pagination setting, it is reported with TOTAL_HITS_RELATION_LOWER_BOUND, and results past that limit can’t be paged to.
  • When topK isn’t set, the component returns up to 20 hits per page.

Native queries

The query.native field of a search request accepts the parameters of the Meilisearch search API, for example q, filter, matchingStrategy, or attributesToCrop. Pagination and sorting use the portable query fields, so a native query must not set offset, limit, page, hitsPerPage, or sort. A native filter is combined with the portable filter using a logical AND, so it can only narrow the results.

{
  "query": {
    "native": { "q": "dapr", "matchingStrategy": "all" },
    "topK": 10
  }
}

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 documents in it are indexed, and a request that waits for completion fails with the task’s error. The component therefore checks the documents that Meilisearch would reject before it sends the task, and reports them in failedItems, as described in document mapping.

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.