zenbook migration

This commit is contained in:
2026-02-08 10:25:39 +01:00
commit 84b8735385
178 changed files with 5350 additions and 0 deletions
+10
View File
@@ -0,0 +1,10 @@
module meilisearch
go 1.23.1
require (
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/meilisearch/meilisearch-go v0.28.0 // indirect
)
+20
View File
@@ -0,0 +1,20 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg=
github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
github.com/meilisearch/meilisearch-go v0.28.0 h1:f3XJ66ZM+R8bANAOLqsjvoq/HhQNpVJPYoNt6QgNzME=
github.com/meilisearch/meilisearch-go v0.28.0/go.mod h1:Szcc9CaDiKIfjdgdt49jlmDKpEzjD+x+b6Y6heMdlQ0=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+107
View File
@@ -0,0 +1,107 @@
package main
import (
"context"
"flag"
"fmt"
"os/signal"
"syscall"
"time"
"github.com/meilisearch/meilisearch-go"
)
func main() {
var hostname, masterKey string
var list bool
flag.StringVar(&hostname, "host", "meili.zerops", "hostname to connect to elastic")
flag.StringVar(&masterKey, "key", "nope", "master key")
flag.BoolVar(&list, "list", false, "whether to list the whole index")
flag.Parse()
ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
defer stop()
client := meilisearch.New(fmt.Sprintf("http://%s:7700", hostname), meilisearch.WithAPIKey(masterKey))
const indexName = "xxx"
taskInfo, err := client.CreateIndexWithContext(ctx, &meilisearch.IndexConfig{
Uid: indexName,
PrimaryKey: "id",
})
if err != nil {
panic(err)
}
status := taskInfo.Status
var taskErr any
for status != "succeeded" {
if status == "failed" || status == "canceled" {
fmt.Println("task failed:", taskErr)
break
}
task, err := client.GetTaskWithContext(ctx, taskInfo.TaskUID)
if err != nil {
panic(err)
}
status = task.Status
taskErr = task.Error
}
indices, err := client.ListIndexesWithContext(ctx, &meilisearch.IndexesQuery{})
if err != nil {
panic(err)
}
for _, index := range indices.Results {
fmt.Println(index.UID, index.PrimaryKey)
}
index := client.Index(indexName)
if list {
resp, err := index.SearchWithContext(ctx, "*", &meilisearch.SearchRequest{Limit: 1024 * 1024})
if err != nil {
panic(err)
}
for _, hit := range resp.Hits {
fmt.Printf("LIST: ==> %s\n", hit.(map[string]any)["message"])
}
}
for {
if ctx.Err() != nil {
fmt.Println("context canceled")
return
}
now := time.Now()
message := now.Format(time.TimeOnly)
document := map[string]any{
"id": now.UnixNano(),
"name": "meili",
"message": message,
}
taskInfo, err = index.AddDocumentsWithContext(ctx, []map[string]any{document})
if err != nil {
panic(err)
}
status = taskInfo.Status
for status != "succeeded" {
if status == "failed" || status == "canceled" {
fmt.Println("task failed:", taskErr)
break
}
task, err := index.GetTaskWithContext(ctx, taskInfo.TaskUID)
if err != nil {
panic(err)
}
status = task.Status
taskErr = task.Error
}
fmt.Printf("==> %s\n", document["message"])
time.Sleep(time.Second)
}
}