Actions181
- Account Actions
- Get Account
- Create Account
- Update Email
- Update Name
- Update Password
- Update Phone
- Update Status
- Get Preferences
- Update Preferences
- List Sessions
- Delete Sessions
- Get Session
- Update Session
- Delete Session
- Create Anonymous Session
- Create Email/Password Session
- Create Magic URL Session
- Create OAuth2 Session
- Create Phone Session
- Create Session from Token
- Create JWT
- Create Magic URL
- Create Phone Token
- Create Email Verification
- Update Email Verification
- Create Phone Verification
- Update Phone Verification
- Create Password Recovery
- Update Password Recovery
- Create Recovery
- Update Recovery
- Update MFA
- Create MFA Authenticator
- Update MFA Authenticator
- Delete MFA Authenticator
- Create MFA Challenge
- Update MFA Challenge
- Attribute Actions
- Avatars Actions
- Collection Actions
- Database Actions
- Document Actions
- Functions Actions
- Index Actions
- Locale Actions
- Messaging Actions
- Sites Actions
- Storage Actions
- Teams Actions
- Users Actions
Index → Create
AI-generatedOverview
This node operation creates an index in a specified database collection within the Appwrite platform. It is useful for organizing and optimizing data retrieval by defining keys, types, and sorting orders for attributes in the collection. Practical examples include creating unique indexes for user IDs, fulltext indexes for search functionality, or key indexes for sorting data.
Use Case Examples
- Creating a unique index on a user email attribute to ensure no duplicates.
- Creating a fulltext index on a product description attribute to enable search capabilities.
- Creating a key index on multiple attributes to optimize query performance.
Properties
| Name | Meaning |
|---|---|
| Database ID | The ID of the database where the index will be created. |
| Collection ID | The ID of the collection within the database where the index will be created. |
| Index Key | The key name for the index. |
| Type | The type of the index, which can be key, fulltext, or unique. |
| Attributes | A comma-separated string of attribute keys that the index will cover. |
| Orders | A comma-separated string of sort orders (ASC or DESC) for the attributes. If empty, default order is used. |
Output
JSON
indexId- The unique identifier of the created index.databaseId- The ID of the database where the index was created.collectionId- The ID of the collection where the index was created.key- The key name of the created index.type- The type of the created index (key, fulltext, unique).attributes- The list of attribute keys included in the index.orders- The sort orders applied to the attributes in the index.
Dependencies
- Appwrite API key credential for authentication and access to the Appwrite service.
Troubleshooting
- Ensure that the provided database ID and collection ID exist and are accessible with the given credentials.
- Verify that the index key is unique within the collection to avoid conflicts when creating a unique index.
- Check that the attributes string is correctly formatted as a comma-separated list without extra spaces or invalid characters.
- If the orders string is provided, ensure it only contains valid values (ASC or DESC) separated by commas.
- Common error messages may include authentication failures, invalid resource IDs, or malformed input parameters. Verify credentials and input data to resolve these issues.