Actions11
Overview
The node enables creating a search index on a specified MongoDB collection. This operation is useful for enhancing query performance and enabling advanced search capabilities within MongoDB Atlas, such as full-text search or vector search. Users can define custom search indexes tailored to their data and query patterns.
Practical examples include:
- Creating a text search index to enable fast keyword searches across documents.
- Defining a vector search index for similarity search in applications like recommendation systems or image retrieval.
Properties
| Name | Meaning |
|---|---|
| Collection | The MongoDB collection on which the search index will be created. |
| Index Name | The unique name assigned to the search index being created. |
| Index Definition | JSON object defining the structure and parameters of the search index. Examples include specifying the type (e.g., vectorSearch) and detailed configuration. |
| Index Type | The type of search index to create. Options are: Vector Search, Search (standard text search). |
Output
The output JSON contains an object with the property indexName indicating the name of the newly created search index. For example:
{
"indexName": "mySearchIndex"
}
This confirms successful creation of the index.
Dependencies
- Requires connection to a MongoDB database with appropriate permissions to create search indexes.
- Needs an API key credential or authentication token configured in n8n to connect securely to MongoDB.
- The MongoDB server must support search indexes (typically MongoDB Atlas with Atlas Search enabled).
Troubleshooting
Common issues:
- Insufficient permissions to create search indexes on the target collection.
- Invalid or malformed JSON in the Index Definition property.
- Specifying an index name that already exists.
- Connection failures due to incorrect credentials or network issues.
Error messages and resolutions:
"Database does not exist": Verify the database name and connection credentials."Invalid JSON": Ensure the Index Definition is valid JSON and follows MongoDB's search index schema."Index name already exists": Use a unique index name or drop the existing index before creating a new one."Permission denied": Check user roles and privileges in MongoDB to allow index creation.