# README
Task Management Example
This example shows how to monitor and manage Meilisearch tasks.
What it does
- Create an index (generates a task)
- Add documents (generates a task)
- Update settings (generates a task)
- Wait for tasks to complete
- Get individual task details
- List all tasks with filters
- Filter tasks by type (document operations only)
Task information shown
For each task you see:
- Task ID and type
- Status (enqueued, processing, succeeded, failed)
- Start and finish times
- Duration
- Error details if it failed
Configuration
export MEILI_HOST="http://localhost:7700"
export MEILI_API_KEY="your-admin-api-key"
Note: You need an admin API key (not a search key) to manage tasks.
Run it
go run ./examples/manage_tasks
Testing connection to Meilisearch...
ā
Connected to Meilisearch (status: available)
1. Creating index for task demonstration...
ā
Task #1 (Index Creation) completed with status: succeeded
Duration: 2ms
2. Adding documents to generate tasks...
ā
Task #2 (Document Addition) completed with status: succeeded
Duration: 15ms
3. Updating settings...
ā
Task #3 (Settings Update) completed with status: succeeded
Duration: 8ms
4. Retrieving individual task information...
Task #2:
- Type: documentAdditionOrUpdate
- Status: succeeded
- Started At: 2024-01-15T10:30:45Z
- Finished At: 2024-01-15T10:30:45Z
- Duration: 15ms
5. Listing all tasks...
Found 3 tasks total
6. Filtering tasks by type...
Found 1 document-related tasks
Task management example completed successfully! š
## Best Practices Shown
- Always wait for critical tasks to complete
- Use appropriate timeouts for task waiting
- Filter tasks efficiently for monitoring
- Handle task errors gracefully
- Monitor task performance with statistics