mirror of
https://github.com/hanzoai/search-go.git
synced 2026-10-30 18:22:58 +00:00
Modules declare go 1.27.1 and the build images follow. go fix applied the modernizers, and the test and example pointer helpers went once new(expr) could say them; omitzero is not applied, since it changes what the JSON says. Co-authored-by: Hanzo Dev <[email protected]>
Document Management Example
This example shows how to manage documents in Meilisearch. You'll learn to add, update, retrieve, and delete documents.
What it does
type User struct {
ID int `json:"id"`
Name string `json:"name"`
Email string `json:"email"`
Role string `json:"role"`
Active bool `json:"active"`
JoinDate string `json:"join_date"`
}
- Create a "users" index
- Add multiple documents at once
- Add single documents
- Update existing documents
- Get documents by ID
- Get multiple documents with pagination
- Delete single document
- Delete multiple documents
Configuration
# Set Meilisearch server URL (defaults to http://localhost:7700)
export MEILI_HOST="http://localhost:7700"
# Set API key (recommended for production)
export MEILI_API_KEY="your-api-key"
Run it
go run ./examples/add_documents