Meilisearch icon

Meilisearch

Consume Meilisearch API

Overview

This node integrates with the Meilisearch API to perform search operations on specified indexes. The "Search Index" operation allows users to query a particular index with flexible parameters such as pagination, filtering, faceting, and result customization. This is useful for applications needing fast, full-text search capabilities over structured data, such as product catalogs, document repositories, or media libraries.

Practical examples include:

  • Searching a movie database by title, genre, or director.
  • Retrieving paginated search results from an e-commerce product index.
  • Filtering documents based on attributes and highlighting matched terms in the results.

Properties

Name Meaning
UID Name of the index to search within. Required.
Search Query The query string to search for in the index.
Offset Number of results to skip before starting to return results (for pagination). Minimum value: 1.
Limit Maximum number of results to return. Minimum value: 1. Default is 50.
Hits Per Page Maximum number of results per page. Minimum value: 1. Default is 50.
Page Request a specific page of results. Minimum value: 1.
Filter String A filter expression to narrow down 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 (shortened).
Crop Length Maximum length of cropped attribute values in words. Minimum value: 1. Default is 10.
Crop Marker String used to mark the boundaries of cropped text.
Attributes To Highlight Comma-separated list of attributes where matching terms should be highlighted.
Highlight Pre Tag String inserted at the start of a highlighted term. Defaults to <em>.
Highlight Post Tag String inserted at the end of a highlighted term. Defaults to </em>.
Show Ranking Score Boolean flag indicating whether to include the ranking score in the results.
Show Matches Position Boolean flag indicating whether to include the positions of matching terms in the results.
Sort Comma-separated list of attributes to sort by, with direction, e.g., price:asc,release_date:desc.
Matching Strategy Strategy for matching query terms within documents. Options are last (default) or all.

Output

The node outputs JSON data representing the search results returned by Meilisearch. This typically includes:

  • An array of matched documents with requested attributes.
  • Pagination information such as offset, limit, total hits.
  • Optional metadata like facets counts, ranking scores, and match positions if requested.
  • Highlighted snippets in the attributes specified for highlighting.

If binary data were involved (not indicated here), it would represent file contents or attachments, but this node focuses on JSON search results only.

Dependencies

  • Requires connection to a Meilisearch instance via its REST API.
  • Needs an API key credential configured in n8n for authentication.
  • The base URL of the Meilisearch server must be provided in the credentials.
  • No other external dependencies are required.

Troubleshooting

  • Common issues:

    • Invalid or missing index UID will cause errors; ensure the index exists.
    • Incorrect filter or facet syntax may lead to query failures.
    • Pagination parameters out of range (e.g., offset < 1) can cause errors.
    • Missing or invalid API credentials will prevent successful requests.
  • Error messages:

    • Authentication errors indicate problems with the API key or host URL.
    • "Index not found" errors mean the specified UID does not exist.
    • Malformed query or filter strings will result in descriptive API errors; verify syntax carefully.
  • Resolutions:

    • Double-check index names and existence in your Meilisearch instance.
    • Validate filter and facet expressions against Meilisearch documentation.
    • Ensure API credentials are correctly set up in n8n.
    • Use default values for pagination fields or provide valid numbers.

Links and References

Discussion