Hanzo
Hanzo Skills Reference

Hanzo Search Go SDK

Go client library for Hanzo Search (Meilisearch compatible). Fork of `meilisearch/meilisearch-go` with module path rewritten to `github.com/hanzoai/search-go`. The Go package name is `meilisearch`....

Overview

Go client library for Hanzo Search (Meilisearch compatible). Fork of meilisearch/meilisearch-go with module path rewritten to github.com/hanzoai/search-go. The Go package name is meilisearch. Provides index management, document CRUD, search with filters/facets/highlighting, settings management, task monitoring, chat, and webhook support.

OSS Base

Fork of meilisearch-go (meilisearch/meilisearch-go). Repo: hanzoai/search-go, branch: main.

Quick reference

ItemValue
Modulegithub.com/hanzoai/search-go
Packagemeilisearch
Version0.36.1
Go1.26+
Repogithub.com/hanzoai/search-go
Branchmain
LicenseMIT
ProtocolHTTP/REST

Installation

go get github.com/hanzoai/search-go

Quick start

package main

import (
    "fmt"

    search "github.com/hanzoai/search-go"
)

func main() {
    client := search.New("http://localhost:7700", search.WithAPIKey("your-api-key"))

    // Create index
    task, _ := client.CreateIndex(&search.IndexConfig{
        Uid:        "movies",
        PrimaryKey: "id",
    })
    fmt.Println("Task:", task.TaskUID)

    // Add documents
    index := client.Index("movies")
    docs := []map[string]interface{}{
        {"id": 1, "title": "Carol", "genres": []string{"Romance", "Drama"}},
        {"id": 2, "title": "Wonder Woman", "genres": []string{"Action"}},
    }
    task, _ = index.AddDocuments(docs, nil)

    // Search
    res, _ := index.Search("wonder", &search.SearchRequest{Limit: 10})
    fmt.Println(res.Hits)
}

Key features

  • Index creation, listing, updating, deletion
  • Document add, update, delete (batch and single)
  • Full-text search with filters, facets, highlighting, sorting
  • Settings management (filterable, sortable, searchable attributes)
  • Multi-search across multiple indexes
  • Facet search
  • Task management (async operations)
  • Chat interface (streaming)
  • Webhook support
  • Content encoding (gzip, deflate, brotli)
  • Configurable retries with backoff
  • JWT-based tenant tokens

Client options

client := search.New("http://localhost:7700",
    search.WithAPIKey("your-api-key"),
    search.WithCustomClient(http.DefaultClient),
    search.WithContentEncoding(search.GzipEncoding, search.BestCompression),
    search.WithCustomRetries([]int{502, 503, 504}, 3),
)
OptionDescription
WithAPIKeyAPI key for authentication
WithCustomClientCustom http.Client
WithCustomClientWithTLSEnable TLS
WithContentEncodingRequest/response encoding
WithCustomRetriesRetry by status code and max retries
DisableRetriesDisable automatic retries

Build and test

go build ./...
go test ./...
# Integration tests require a running Meilisearch instance

How is this guide?

Last updated on

On this page