Actions44
- User Actions
- Database Actions
- Collection Actions
- Document Actions
- Index Actions
- Function Actions
- Storage Actions
Overview
This node enables managing indexes within a specified database collection in the Appwrite backend service. It supports creating, retrieving, listing, and deleting indexes on collections, which helps optimize query performance and enforce data constraints.
Common scenarios include:
- Creating an index to speed up queries filtering or sorting by certain attributes.
- Defining unique indexes to ensure attribute values remain unique across documents.
- Adding full-text search capabilities on string attributes for advanced search features.
For example, you might create a "key" type index on the "email" attribute of a users collection to quickly filter users by email, or a "unique" index to prevent duplicate usernames.
Properties
| Name | Meaning |
|---|---|
| Database ID | ID of the database containing the collection where the index will be managed. |
| Collection ID | ID of the collection on which the index operations will be performed. |
| Key | A unique key identifier for the index. |
| Type | The type of index to create. Options: - Key: Standard index for sorting and filtering. - Full-text: Index for searching within string attributes. - Unique: Enforces uniqueness of attribute values. |
| Attributes | JSON array of attribute keys to include in the index. Example: ["name", "email"]. |
| Orders | JSON array specifying ordering directions ("ASC" or "DESC") for each attribute. Only applicable for "Key" type indexes. Example: ["ASC"]. |
Output
The node outputs JSON data representing the result of the index operation:
- For create operations, it returns the created index object with details such as its key, type, attributes, and order.
- For get operations, it returns the specific index's details.
- For list operations, it returns an array of index objects for the specified collection.
- For delete operations, it returns a success confirmation object
{ success: true }.
No binary data output is involved in this resource's operations.
Dependencies
- Requires an API authentication token credential configured in n8n to connect to the Appwrite backend.
- Depends on the Appwrite SDK client initialized with the provided credentials.
- The node expects valid database and collection IDs to perform index management.
Troubleshooting
- Invalid Database or Collection ID: Ensure that the provided IDs exist and are correct; otherwise, the API will return errors indicating not found resources.
- Duplicate Key Error: When creating an index, the key must be unique within the collection. Attempting to create an index with an existing key will cause an error.
- Malformed JSON for Attributes or Orders: The
attributesandordersfields expect valid JSON arrays. Invalid JSON syntax will cause parsing errors. - Unsupported Order for Non-Key Index Types: The
ordersproperty should only be used when the index type is "Key". Using it with other types may cause unexpected behavior or errors. - API Authentication Errors: Verify that the API key credential is correctly set up and has sufficient permissions to manage indexes.
If the node throws an error, check the error message for details. Common messages include missing parameters, invalid JSON, or permission denied.