younifyd
Menu

Edit documents by function

Edit documents by function

POST/indexes/{index_uid}/documents/edit

Use it in a workflow

  1. Add a step and choose the Meilisearch connector.
  2. Pick the Edit documents by function action (under Documents).
  3. Fill in the fields below, then reference the result from later steps as {{editDocumentsByFunction.response.data}}.

Request

Path parameters

index_uidstringrequired

Unique identifier of the index.

Query parameters

customMetadatastring

A string that can be used to identify and filter tasks. This metadata is stored with the task and returned in task responses. Useful for tracking tasks from external systems or associating tasks with specific operations in your application.

Request body

Enter the body as JSON in the step's Body field.

filterany

Filter expression to select which documents to edit. If omitted, all documents in the index will be processed. Attributes must be in `filterableAttributes` to be used.

contextany

Arbitrary data to pass into the function scope. By default the function only has access to the current document being edited via the `doc` variable.

functionstringrequired

A [RHAI](https://rhai.rs) function string to apply to each document. The function has access to a `doc` variable representing the current document. Modify `doc` fields to update the document. Return `null` or `()` to delete the document. To enable this feature: `PATCH /experimental-features/ {"editDocumentsByFunction": true}`.

json
{
  "function": "string",
  "filter": null,
  "context": null
}

Response

Returns 202 with an object. Read it in later steps with {{editDocumentsByFunction.response.data.<field>}}.

taskUidinteger (u-int32)

Unique sequential identifier of the task.

indexUidstring | null

Unique identifier of the targeted index. Null for global tasks.

statusstring

The status of a task.

One ofenqueuedprocessingsucceededfailedcanceled

typestring

The type of the task.

One ofdocumentAdditionOrUpdatedocumentEditiondocumentDeletionsettingsUpdateindexCreationindexDeletionindexUpdateindexSwaptaskCancelationtaskDeletiondumpCreationsnapshotCreationexportupgradeDatabaseindexCompactionnetworkTopologyChangedsrUpdatedsrClear

enqueuedAtstring (date-time)

Date and time when the task was enqueued.

customMetadatastring | null

Custom metadata attached to this task at creation. Use it to associate tasks with external systems or add application-specific information.

json
{
  "taskUid": 0,
  "status": "processing",
  "type": "documentAdditionOrUpdate",
  "enqueuedAt": "2025-01-01T00:00:00Z",
  "indexUid": "string",
  "customMetadata": "string"
}

Need more? See the Meilisearch guide for connection setup and behaviour shared by every action.