Unofficial Experimental AppSearch API client for Go.
- Schema-aligned Marshal/Unmarshal of complex structures
- Engine API Godoc | ElasticSearch Reference
- Schema API Godoc | ElasticSearch Reference
- Document API Godoc | ElasticSearch Reference
- Deriving schemas from structure with tags
- Implement complete set of Elastic App Search API's
package main import ( "context" "github.com/lithiumlabcompany/appsearch" "github.com/lithiumlabcompany/appsearch/pkg/schema" ) type Civilization struct { Name string Rating float32 Description string } func main() { client, _ := appsearch.Open("https://private-key@endpoint.ent-search.cloud.es.io") ctx, cancel := context.WithCancel(context.Background()) defer cancel() engineName := "civilizations" schemaDefinition := schema.Definition{ "name": "text", "rating": "number", "description": "text", } // Engine will be created if it doesn't exist and schema will be updated client.EnsureEngine(ctx, appsearch.CreateEngineRequest{ Name: "civilizations", Language: "en", }, schemaDefinition) // Also supports marshaling nested structures documents, _ := schema.Marshal([]Civilization{{ Name: "Babylonian", Rating: 5212.2, Description: "Technological and scientific", }}, schemaDefinition) // Also accepts any normalized JSON-serializable input client.UpdateDocuments(ctx, "civilizations", documents) search, _ := client.SearchDocuments(ctx, engineName, appsearch.Query{ Query: "scientific", }) var results []Civilization _ = schema.UnpackSlice(search.Results, &results) println(results[0]) }