Golang SDK for Azure Search
This is a golang SDK for the Azure Search APIs.
It currently only supports searching documents in existing index.
Get started
- Use the depedency in your project.
go get -d github.com/vippsas/go-azsearch
- Create a client in you app.
import "github.com/vippsas/go-azsearch/azs"
func main() {
cfg := azs.Config{
AzsApiKeyType: "", // Your Api key type (admin or query)
AzsApiKey: "", // Your Api key (query key or admin key)
AzsInstanceName: "", // Your search instance `https://{instance}.search.windows.net`
}
cli, err := azs.NewClient(&cfg, http.DefaultClient, func(ctx context.Context) logrus.FieldLogger {
// You can retrieve your request bound logger here.
return logrus.New()
})
if err != nil {
fmt.Println("Failed to init client")
return
}
}
- Search documents in your index
var target azs.SearchResponse
err = cli.Search(context.Background(), "countries", &azs.SearchRequest{Search: "Norwa"}, &target)
if err != nil {
// Handle error
}
APIs supported