Meilisearch icon

Meilisearch

Consume Meilisearch API

Overview

The Meilisearch node's "Tasks" resource with the "Cancel Tasks" operation allows you to cancel one or more tasks in a Meilisearch instance. This is useful for managing and controlling background operations, such as stopping long-running or unnecessary indexing, update, or delete jobs. Common scenarios include aborting tasks that are no longer needed, freeing up system resources, or responding to user-initiated cancellations.

Practical examples:

  • Cancel all tasks of a certain type that were enqueued before a specific date.
  • Stop tasks related to a particular index if an error was detected elsewhere in your workflow.
  • Bulk-cancel tasks by their unique identifiers (UIDs).

Properties

Name Meaning
Additional Fields A collection of optional filters to specify which tasks to cancel. Each field refines the cancellation criteria.
UIDs Comma-delimited list of task UID(s) to filter results by.
Index UIDs Comma-delimited list of Index UID(s) to filter results by.
Statuses Comma-delimited list of Task Status(es) to filter results by.
Types Comma-delimited list of Task Type(s) to filter results by.
Canceled By Comma-delimited list of Task UID(s) that canceled another task(s).
Before Enqueued At Filter tasks enqueued before this date/time.
After Enqueued At Filter tasks enqueued after this date/time.
Before Started At Filter tasks started before this date/time.
After Started At Filter tasks started after this date/time.
Before Finished At Filter tasks finished before this date/time.
After Finished At Filter tasks finished after this date/time.

Output

The output will be a JSON object containing information about the canceled tasks. While the exact structure depends on the Meilisearch API response, it typically includes:

{
  "results": [
    {
      "uid": 123,
      "status": "canceled",
      "type": "documentAddition",
      "enqueuedAt": "2023-01-01T12:00:00Z",
      // ...other task fields
    }
    // ...more tasks
  ],
  "limit": 20,
  "offset": 0,
  "total": 2
}
  • results: Array of canceled task objects, each with details like uid, status, type, and timestamps.
  • limit, offset, total: Pagination information.

Note: The node does not output binary data.


Dependencies

  • External Service: Requires access to a running Meilisearch instance.
  • API Key: Needs a valid Meilisearch API key with sufficient permissions.
  • n8n Credentials: Must configure the meilisearchApi credential in n8n, including the host_url.

Troubleshooting

Common Issues:

  • Invalid API Key: If the API key is missing or lacks permission, you may receive authentication errors.
  • Incorrect Filters: Using invalid UIDs or malformed date strings can result in empty results or API errors.
  • Network Errors: Connectivity issues between n8n and Meilisearch can cause request failures.

Error Messages & Resolutions:

  • "401 Unauthorized": Check your API key and permissions.
  • "400 Bad Request": Verify that all filter values (e.g., dates, UIDs) are correctly formatted.
  • "404 Not Found": Ensure the specified tasks or indexes exist.

Links and References

Discussion