Meilisearch Integration
Want to build powerful search into your workflows? Connect Meilisearch to SmythOS and let your agents manage indexes, add documents, and run complex search queries automatically.
List of Meilisearch Components
Quickly compare Meilisearch components by what they do and their key I/O. Click any component name to jump directly to its detailed guide.
Component | Action | What it Does | Inputs | Key Outputs | Use Case |
---|---|---|---|---|---|
Full Text Search | Search | Searches for documents within a specified index. | required url , index_uid , query | results | Power a search bar in your application. |
Create an Index | Setup | Creates a new, empty index with a primary key. | required url , uid , primaryKey | taskUid | Set up a new data collection for searching. |
Add a Single Document | Write | Adds or updates one document in an index. | required url , index_uid optional body | taskUid | Index a new user profile as it's created. |
Add Documents | Write | Adds or updates a batch of documents in an index. | required url , uid optional body | taskUid | Perform a bulk import of product data. |
Update a Document | Write | Adds or updates documents in an index. (Similar to Add Documents). | required url , index_uid optional body | taskUid | Update product inventory levels in bulk. |
Delete a Document | Write | Deletes a single document from an index. | required url , index_uid , document_id | taskUid | Remove a user's data upon account deletion. |
Update Synonyms | Setup | Updates the list of synonyms for an index to improve search relevance. | required url , index_uid optional body | taskUid | Make "t-shirt" and "tee" return the same results. |
Prerequisites
Before you begin, please ensure you have the following:
- An active SmythOS account. (Sign up here).
- A running Meilisearch instance, either self-hosted or on Meilisearch Cloud.
- The Host URL of your Meilisearch instance (e.g.,
https://my-instance.meilisearch.com
). - Your Meilisearch Master Key.
Getting Started With Meilisearch
The connection between SmythOS and Meilisearch is configured using your instance's URL and a secure Master Key.
Step 1: Locate Your Meilisearch Credentials
- Host URL: This is the main URL you use to access your Meilisearch instance.
- Master Key: In your Meilisearch instance, navigate to Settings -> API Keys. Your Master Key is displayed there. It has full permissions to perform any action.
Step 2: Store Your Master Key in SmythOS Vault
Your Master Key is highly sensitive. Use the SmythOS Vault
to store it securely.
- In your SmythOS dashboard, navigate to the Vault.
- Create a new secret and paste your Meilisearch Master Key as the value. Give it a memorable name, like
meilisearch_master_key
. - For more details, see the Vault Documentation.
Step 3: Configure a Meilisearch Component
- In your SmythOS agent graph, drag and drop any Meilisearch component.
- Click the component to open its Settings panel.
- In the
Master Key
field, select the secret you saved in the Vault (e.g.,meilisearch_master_key
). - In the component's Inputs, provide the
url
of your Meilisearch instance. - Your connection is now configured for that component.
Which Meilisearch Component Should I Use?
If you need to… | Target | Use this Component | Why this one? |
---|---|---|---|
Implement search functionality | An index uid and a query | Full Text Search | The core component for all search operations. |
Index a large dataset | An array of documents | Add Documents | Optimized for adding or updating items in bulk. |
Index a single new item | A single document object | Add a Single Document | Perfect for real-time indexing as items are created. |
Delete an item | A document_id | Delete a Document | Removes a specific document from your search index. |
Set up a new search space | A uid and primaryKey | Create an Index | The first step for any new dataset you want to make searchable. |
Improve search relevance | A list of synonym pairs | Update Synonyms | Helps Meilisearch understand related terms. |
Component Details
This section provides detailed information for each Meilisearch component.
Full Text Search
Searches for documents matching a query within a given index.
Inputs
Field | Required | Notes |
---|---|---|
url | required | The base URL of your Meilisearch instance. |
index_uid | required | The unique identifier of the index to search in. |
query | required | The search term or phrase. |
Outputs
Field | Description |
---|---|
results | An array of document objects that match the search query. |
response | The raw JSON response from the Meilisearch API, including metadata like hits , limit , etc. |
headers | HTTP headers from the API response. |
{
"component": "meilisearch.fullTextSearch",
"url": "[https://my-instance.meilisearch.com](https://my-instance.meilisearch.com)",
"index_uid": "products",
"query": "retro t-shirt"
}
Create an Index
Creates a new search index. An index is a collection of documents that you can search through.
Inputs
Field | Required | Notes |
---|---|---|
url | required | The base URL of your Meilisearch instance. |
uid | required | The unique identifier for the new index (e.g., "movies", "products"). |
primaryKey | required | The attribute in your documents that serves as a unique identifier (e.g., "id", "sku"). |
Outputs
Field | Description |
---|---|
taskUid | The UID of the asynchronous task. Use this to track the status of the index creation. |
response | The raw JSON response from the Meilisearch API. |
headers | HTTP headers from the API response. |
{
"component": "meilisearch.createIndex",
"url": "[https://my-instance.meilisearch.com](https://my-instance.meilisearch.com)",
"uid": "users",
"primaryKey": "user_id"
}
Add a Single Document
Adds or updates a single document in a specified index. If the index doesn't exist, it will be created.
Inputs
Field | Required | Notes |
---|---|---|
url | required | The base URL of your Meilisearch instance. |
index_uid | required | The index where the document will be added. |
body | optional | A JSON object representing the document to be added. This is configured in the component settings. |
Outputs
Field | Description |
---|---|
taskUid | The UID of the asynchronous task for this indexing operation. |
response | The raw JSON response from the Meilisearch API. |
headers | HTTP headers from the API response. |
{
"component": "meilisearch.addSingleDocument",
"url": "[https://my-instance.meilisearch.com](https://my-instance.meilisearch.com)",
"index_uid": "users",
"body": {
"user_id": 123,
"name": "John Doe",
"email": "john.doe@example.com"
}
}
Add Documents
Adds or updates a batch of documents in an index. This is more efficient than adding documents one by one.
Inputs
Field | Required | Notes |
---|---|---|
url | required | The base URL of your Meilisearch instance. |
uid | required | The index where the documents will be added. |
body | optional | An array of JSON objects representing the documents. This is configured in the component settings. |
Outputs
Field | Description |
---|---|
taskUid | The UID of the asynchronous task for this bulk indexing operation. |
response | The raw JSON response from the Meilisearch API. |
headers | HTTP headers from the API response. |
{
"component": "meilisearch.addDocuments",
"url": "[https://my-instance.meilisearch.com](https://my-instance.meilisearch.com)",
"uid": "products",
"body": [
{ "id": 1, "name": "Laptop" },
{ "id": 2, "name": "Mouse" }
]
}
Update a Document
Adds a list of documents or updates them if they already exist in a specified index. If the provided index does not exist, it will be created automatically.
Inputs
Field | Required | Notes |
---|---|---|
url | required | The base URL of your Meilisearch instance. |
index_uid | required | The unique identifier of the index you want to use. |
body | optional | An array of JSON objects representing the documents to add or update. This is configured in the component settings. |
Outputs
Field | Description |
---|---|
taskUid | The UID of the asynchronous task for this indexing operation. |
response | The raw JSON response from the Meilisearch API. |
headers | HTTP headers from the API response. |
{
"component": "meilisearch.updateDocument",
"url": "[https://my-instance.meilisearch.com](https://my-instance.meilisearch.com)",
"index_uid": "inventory",
"body": [
{ "sku": "t-shirt-red", "stock": 50, "price": 19.99 },
{ "sku": "t-shirt-blue", "stock": 35, "price": 21.99 }
]
}
Delete a Document
Deletes a single document from a specified index using its unique document ID.
Inputs
Field | Required | Notes |
---|---|---|
url | required | The base URL of your Meilisearch instance. |
index_uid | required | The index from which to delete the document. |
document_id | required | The unique ID of the document to delete. This is the value of the primaryKey . |
Outputs
Field | Description |
---|---|
taskUid | The UID of the asynchronous deletion task. |
response | The raw JSON response from the Meilisearch API. |
headers | HTTP headers from the API response. |
{
"component": "meilisearch.deleteDocument",
"url": "[https://my-instance.meilisearch.com](https://my-instance.meilisearch.com)",
"index_uid": "users",
"document_id": "123"
}
Update Synonyms
Updates the list of synonyms for an index to improve search relevance. Synonyms are normalized.
Inputs
Field | Required | Notes |
---|---|---|
url | required | The base URL of your Meilisearch instance. |
index_uid | required | The index whose synonyms you want to update. |
body | optional | A JSON object where keys are words and values are arrays of their synonyms. Configured in settings. |
Outputs
Field | Description |
---|---|
taskUid | The UID of the asynchronous task for this settings update. |
response | The raw JSON response from the Meilisearch API. |
headers | HTTP headers from the API response. |
{
"component": "meilisearch.updateSynonyms",
"url": "[https://my-instance.meilisearch.com](https://my-instance.meilisearch.com)",
"index_uid": "clothes",
"body": {
"pants": ["trousers", "slacks"],
"tshirt": ["tee", "t-shirt"]
}
}
Best Practices & Advanced Tips
- Use the SmythOS Vault: Your Meilisearch Master Key provides full administrative access. Always store it in the SmythOS
Vault
and never expose it directly in your components. - Track Asynchronous Tasks: Most write operations in Meilisearch (add, update, delete) are asynchronous and return a
taskUid
. You can build logic in your agent to poll the Meilisearch Tasks API with this UID to confirm when an operation has been successfully processed. - Batch Operations: For indexing large amounts of data, always use the
Add Documents
component instead ofAdd a Single Document
in a loop. Batching is significantly more performant. - Schema Design: Before indexing, carefully design the schema for your documents. Deciding on a consistent
primaryKey
and which fields should be searchable or filterable is crucial for a good search experience. - Understand Filterable Attributes: To filter search results (e.g., by price, category), you must first configure those attributes as "filterable" in your Meilisearch index settings. This is another task that can be automated with an agent.
Troubleshooting Common Issues
-
Error:
403 Forbidden
- Cause: The API key used is incorrect or does not have sufficient permissions.
- Solution: Verify that you are using the Master Key (not a search-only key) and that it is correctly stored and referenced from the SmythOS Vault.
-
Error:
404 Not Found
for an index- Cause: The
index_uid
you provided does not exist. - Solution: Double-check the spelling and case of your
index_uid
. You can use the Meilisearch Indexes API to list all existing indexes to confirm the name.
- Cause: The
-
Error:
missing_document_id
- Cause: You are trying to add a document that does not contain the field designated as the
primaryKey
for that index. - Solution: Ensure every document you send to Meilisearch includes the unique
primaryKey
field (e.g.,id
,sku
,objectID
).
- Cause: You are trying to add a document that does not contain the field designated as the
-
Search results are not updating after adding documents
- Cause: Indexing is an asynchronous process. It might take a moment for new documents to become searchable.
- Solution: Use the
taskUid
returned by write operations to check the status of the task. Only expect to find the document in search results after the task status issucceeded
.
What's Next?
You're now equipped to integrate lightning-fast search into your automated workflows with the SmythOS Meilisearch Integration!
Consider these next steps:
- Build an Agent That...
- Syncs your entire user database from PostgreSQL into a "users" index every night.
- Listens for new blog posts on a WordPress site and automatically adds them to a "posts" index for your website's search bar.
- Connects to a product information system, updates the "products" index in real-time as inventory changes, and uses
Update Synonyms
to improve product discovery.