Giter VIP home page Giter VIP logo

algoliasearch-client-go's Introduction

Algolia for Go

The perfect starting point to integrate Algolia within your Go project

CircleCI Github Releases GoDoc Go Report Card License Supported version

DocumentationCommunity ForumStack OverflowReport a bugFAQSupport

✨ Features

  • Support Go 1.11 and above
  • Typed requests and responses
  • First-class support for user-defined structures
  • Injectable HTTP client

Migration note from v2.x to v3.x

In June 2019, we released v3 of our Go client. If you are using version 2.x of the client, read the migration guide to version 3.x. Version 2.x will no longer be under active development.

💡 Getting Started

First, add the Algolia Go API Client as a new module to your Go project:

# First line is optional if your project is already defined as a Go module
go mod init <YOUR_PROJECT_NAME>
go get github.com/algolia/algoliasearch-client-go/[email protected]

Then, create objects on your index:

package main

import "github.com/algolia/algoliasearch-client-go/v3/algolia/search"

type Contact struct {
	ObjectID string `json:"objectID"`
	Name     string `json:"name"`
}

func main() {
	client := search.NewClient("YourApplicationID", "YourAPIKey")
	index := client.InitIndex("your_index_name")

	res, err := index.SaveObjects([]Contact{
		{ObjectID: "1", Name: "Foo"},
	})
}

Finally, you may begin searching a object using the Search method:

package main

import (
	"fmt"
	"os"

	"github.com/algolia/algoliasearch-client-go/v3/algolia/search"
)

type Contact struct {
	ObjectID string `json:"objectID"`
	Name     string `json:"name"`
}

func main() {
	client := search.NewClient("YourApplicationID", "YourAPIKey")
	index := client.InitIndex("your_index_name")

	res, err := index.Search("Foo")
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}

	var contacts []Contact

	err = res.UnmarshalHits(&contacts)
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}

	fmt.Println(contacts)
}

For full documentation, visit the Algolia Go API Client.

❓ Troubleshooting

Encountering an issue? Before reaching out to support, we recommend heading to our FAQ where you will find answers for the most common issues and gotchas with the client.

🐳 Use the Dockerfile

If you wish to contribute to the repository but would like to avoid installing the dependencies locally, we provided you with a Docker image. Please check our dedicated guide to learn more.

📄 License

Algolia Go API Client is an open-sourced software licensed under the MIT license.

algoliasearch-client-go's People

Contributors

albertbrand avatar algoliareadmebot avatar andyhaskell avatar ant-hem avatar argon avatar aseure avatar chloelbn avatar csquared avatar elpicador avatar escholtz avatar ferhatelmas avatar fsenart avatar jerska avatar julienbourdeau avatar k-yomo avatar kujenga avatar l4u avatar leoercolanelli avatar marchelbling avatar nagriar avatar odeke-em avatar pixelastic avatar poweroftrue avatar rayrutjes avatar redox avatar sarahdayan avatar speedblue avatar vladislavfitz avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.