Installation

edit

To install the 7.x version of the client, add the package to your go.mod file:

require github.com/elastic/go-elasticsearch/v7 7.16

Or, clone the repository:

git clone --branch 7.16 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

cat > go.mod <<-END
  module my-elasticsearch-app

  require github.com/elastic/go-elasticsearch/v8 main
END

cat > main.go <<-END
  package main

  import (
    "log"

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

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

go run main.go

Elasticsearch Version Compatibility

edit

Language clients are forward compatible; meaning that clients support communicating with greater or equal minor versions of Elasticsearch. Elasticsearch language clients are only backwards compatible with default distributions and without guarantees made.