Meilisearch icon

Meilisearch

Consume Meilisearch API

Overview

The "Add or Replace Documents" operation for the "Documents" resource in this custom n8n node allows you to add new documents or replace existing ones within a specified Meilisearch index. This is useful when you want to update your search index with new data or refresh existing records. Common scenarios include synchronizing a database with Meilisearch, bulk uploading content, or updating product catalogs for search functionality.

Practical examples:

  • Uploading a batch of new articles to a news website's search index.
  • Replacing outdated product information in an e-commerce site's search backend.
  • Periodically syncing user profiles from a CRM to keep search results up-to-date.

Properties

Name Meaning
Index UID Name of the Meilisearch index where documents will be added or replaced. You can select from available indexes; each option shows the index UID and its primary key.
Documents JSON The JSON object(s) representing the documents to add, update, or replace. Must be valid JSON. You can use expressions like {{ JSON.stringify($json) }} or {{ JSON.stringify($jmespath($input.all(), "[] .json")) }}.

Output

  • The output will contain the response from the Meilisearch API after attempting to add or replace the documents.
  • Typically, the response includes a task identifier (e.g., taskUid) that can be used to track the status of the indexing operation.
  • The output is in JSON format and may look like:
{
  "taskUid": 123,
  "indexUid": "my_index",
  "status": "enqueued",
  "type": "documentAdditionOrUpdate",
  "enqueuedAt": "2024-06-01T12:34:56Z"
}
  • No binary data is produced by this operation.

Dependencies

  • External Service: Requires access to a running Meilisearch instance.
  • API Key: Needs a valid Meilisearch API key configured in n8n credentials (meilisearchApi).
  • Environment Variable: The base URL for Meilisearch must be set in the credentials as host_url.

Troubleshooting

Common issues:

  • Invalid JSON: If the "Documents JSON" property contains malformed JSON, the node will fail. Ensure your input is valid JSON.
  • Index Not Found: If the specified Index UID does not exist, Meilisearch will return an error. Double-check the selected index.
  • Permission Denied: If the API key lacks sufficient permissions, you may receive an authentication or authorization error.
  • Large Payloads: Sending very large batches of documents may result in timeouts or errors from Meilisearch.

Error messages and resolutions:

  • "Invalid JSON": Check your "Documents JSON" input for syntax errors.
  • "Index not found": Make sure the index exists in your Meilisearch instance.
  • "Unauthorized" or "Forbidden": Verify your API key and its permissions.

Links and References

Discussion