Loading

Installation

To install the 9.x version of the client for Go, you can use the go get command:

go get github.com/elastic/go-elasticsearch/v9@v9.3.1
		

Or, add the package to your go.mod file:

require github.com/elastic/go-elasticsearch/v9 9.3
		

Or, clone the repository:

git clone --branch 9.3 https://github.com/elastic/go-elasticsearch.git $GOPATH/src/github
		

To install another version, modify the path or the branch name accordingly. The client major versions correspond to the Elasticsearch major versions.

You can find a complete example of installation below:

mkdir my-elasticsearch-app && cd my-elasticsearch-app && go mod init my-elasticsearch-app

go get github.com/elastic/go-elasticsearch/v9@v9.3.1

cat > main.go <<-END
  package main

  import (
    "context"
    "log"

    "github.com/elastic/go-elasticsearch/v9"
  )

  func main() {
    es, _ := elasticsearch.NewDefaultClient()
    defer es.Close(context.Background())
    log.Println(elasticsearch.Version)
    log.Println(es.Info())
  }
END

go run main.go
		

The language clients are forward compatible; meaning that the clients support communicating with greater or equal minor versions of Elasticsearch without breaking. It does not mean that the clients automatically support new features of newer Elasticsearch versions; it is only possible after a release of a new client version. For example, a 8.12 client version won't automatically support the new features of the 8.13 version of Elasticsearch, the 8.13 client version is required for that. Elasticsearch language clients are only backward compatible with default distributions and without guarantees made.

Elasticsearch Version Elasticsearch-Go Branch Supported
main main
9.x 9.x 9.x
8.x 8.x 8.x