Skip to content
This repository was archived by the owner on Feb 4, 2025. It is now read-only.

ewa-learn-english/appsearch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

appsearch

codecov

Unofficial Experimental AppSearch API client for Go.

Godoc | Elastic AppSearch API

Features

TODO

  • Deriving schemas from structure with tags
  • Implement complete set of Elastic App Search API's

Quickstart

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]) }