Meilisearch icon

Meilisearch

Consume Meilisearch API

Overview

The Meilisearch node's "Indexes" resource with the "Search Index" operation allows you to perform advanced search queries on a specific Meilisearch index. This is useful for retrieving documents that match complex criteria, filtering, faceting, sorting, and customizing the returned data from your Meilisearch instance.

Common scenarios:

  • Building search features in applications (e.g., product search, document lookup).
  • Filtering and paginating large datasets.
  • Retrieving only specific fields or facets from indexed documents.
  • Implementing full-text search with highlighting and custom matching strategies.

Practical example:
You could use this node to search a "movies" index for horror films directed by "Jordan Peele", returning only the title and release date, with results highlighted and paginated.


Properties

Name Meaning
UID Name of the index to search within. Selectable from available indexes.
Additional Fields Collection of optional parameters to refine the search. See below for details.
└ Search Query The query string to search for within the index.
└ Offset Number of results to skip (for pagination).
└ Limit Maximum number of results to return.
└ Hits Per Page Maximum number of results per page.
└ Page Specific page of results to request.
└ Filter String Query string to filter results (e.g., (genres = horror OR genres = mystery) AND director = 'Jordan Peele').
└ Facets String Comma-separated list of facets to display counts for. Use * to get all facets.
└ Attributes To Retrieve Comma-separated list of attributes to include in the returned documents.
└ Attributes To Crop Comma-separated list of attributes whose values should be cropped.
└ Crop Length Maximum length (in words) for cropped attribute values.
└ Crop Marker String used to mark crop boundaries.
└ Attributes To Highlight Comma-separated list of attributes where matching terms will be highlighted.
└ Highlight Pre Tag String inserted at the start of a highlighted term (default: <em>).
└ Highlight Post Tag String inserted at the end of a highlighted term (default: </em>).
└ Show Matches Position Boolean; whether to return the location of matching terms in the result.
└ Sort Comma-separated list of attributes and sort directions (e.g., price:asc,release_date:desc).
└ Matching Strategy Strategy for matching query terms within documents. Options: Last, All.

Output

The node returns a JSON object containing the search results from the specified Meilisearch index. The structure typically includes:

{
  "hits": [ /* array of matched documents */ ],
  "offset": 0,
  "limit": 20,
  "processingTimeMs": 1,
  "query": "search term",
  "estimatedTotalHits": 100,
  // ...other metadata depending on options (facets, matchesPosition, etc.)
}
  • hits: Array of documents matching the search query, each as a JSON object.
  • offset/limit/page: Pagination information.
  • facetsDistribution: (if requested) Facet counts.
  • matchesPosition: (if enabled) Locations of matches within fields.
  • highlighted/cropped fields: If highlighting/cropping is enabled, these fields will contain marked-up strings.

No binary data is output by this operation.


Dependencies

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

Troubleshooting

Common issues:

  • Invalid Index UID: If the selected UID does not exist, the node will return an error. Ensure the index exists in your Meilisearch instance.
  • Authentication Errors: Incorrect or missing API key will cause authentication failures.
  • Malformed Query/Filter: Syntax errors in filter or query strings can lead to failed requests. Double-check your filter syntax.
  • Pagination Out of Range: Requesting a page or offset beyond the available results will return empty hits.

Error messages and resolutions:

  • "Index not found": Check the UID property and ensure the index exists.
  • "Invalid API key": Verify your Meilisearch credentials in n8n.
  • "Bad request": Review additional field values, especially filters and sort strings, for correct syntax.

Links and References

Discussion