Elastic
A fluent, idiomatic Go client for Elasticsearch 7.x with cluster sniffing, retries, and a fully typed query DSL.
Repository Health
Technical Analysis
Elastic (import path github.com/olivere/elastic/v7) is a community-maintained Go client for Elasticsearch, offering a fluent, builder-style API that mirrors nearly the entire Elasticsearch 7.x REST surface — CRUD, bulk indexing, the full query DSL, bucket and pipeline aggregations, cat/cluster/indices administration, and X-Pack security, ILM, and rollup endpoints. Rather than hand-building request JSON, callers chain typed service constructors such as NewSearchService, NewBulkService, and NewIndexService, each of which composes a request and unmarshals the response into Go structs.
Under the hood the client manages its own connection pool with configurable health-checking and node sniffing, so it can discover cluster topology and route around failed nodes without extra application code. It supports pluggable retriers, a swappable JSON decoder (falling back to mailru/easyjson for hot paths), OpenTracing/OpenCensus/OpenTelemetry tracing hooks, and a companion aws/ subpackage for AWS SigV4-signed requests to managed OpenSearch/Elasticsearch clusters. The v7 line targets Elasticsearch 7.x specifically; the repository’s README notes it is community-maintained and points newer projects toward the official go-elasticsearch client, so it’s best suited for existing codebases already built on it or teams who prefer its query-builder ergonomics.
What You Get
- Fluent, chainable service builders (NewSearchService, NewBulkService, NewIndexService, NewUpdateService, and dozens more) covering nearly every Elasticsearch 7.x REST endpoint
- A typed query DSL with one Go type per query kind (match, bool, nested, geo, span, percolator, script_score, and more), avoiding hand-written JSON query bodies
- Built-in cluster awareness: configurable health-checking, node sniffing/discovery, dead-node tracking, and pluggable Retrier implementations
- Bulk indexing helpers including a background BulkProcessor for buffered, flush-on-threshold batch writes
- Pluggable JSON decoding (standard library or mailru/easyjson) and tracing integration via OpenTracing, OpenCensus, or OpenTelemetry
- An aws/ subpackage for signing requests with AWS SigV4, for use against managed OpenSearch/Elasticsearch services
Common Use Cases
- Adding full-text search to a Go backend service without hand-rolling Elasticsearch’s JSON query DSL
- Bulk-indexing large datasets into Elasticsearch using the BulkService or BulkProcessor with automatic batching
- Running aggregation-heavy analytics queries (date histograms, terms, percentiles) against an Elasticsearch cluster from Go
- Operating and administering an Elasticsearch cluster programmatically — index templates, ILM policies, snapshots, and cat APIs
- Connecting to AWS-managed OpenSearch/Elasticsearch domains with SigV4-signed requests via the bundled aws/ package
Under The Hood
Architecture
The central Client type (client.go) owns the connection pool, health-checker, and sniffer, while every API endpoint is exposed as a standalone service file (search.go, bulk.go, index.go, cat_.go, indices_.go, xpack_*.go) constructed via a NewXxxService(client) factory that accumulates parameters through chained setters and executes on .Do(ctx); request execution, retry policy (retrier.go), and error normalization (errors.go, wrapping failures into typed *elastic.Error) are centralized in connection.go/request.go so individual services stay thin. This flat one-file-per-endpoint layering keeps each service easy to trace in isolation but means the core Client’s sniffing/connection logic is decoupled from, and must be kept in sync with, hundreds of independent service files.
Tech Stack Built for Go 1.17+ as a zero-web-framework client library; dependencies include github.com/pkg/errors for wrapped errors, mailru/easyjson for an optional fast-path JSON codec (generated _easyjson.go variants), opentracing-go/go.opencensus.io/go.opentelemetry.io/otel for tracing, and aws-sdk-go plus smartystreets/go-aws-auth in the aws/ subpackage for SigV4 signing. Testing and local development rely on docker-compose.yml/docker-compose.cluster.yml to spin up real single-node and multi-node Elasticsearch clusters for integration tests, driven by a Makefile.
Code Quality
The repository ships 276 _test.go files, a large share of them *_integration_test.go variants that run against the docker-compose Elasticsearch clusters (CI’s test-v7.yml workflow runs go test -race -deprecations -strict-decoder against a live cluster), alongside CodeQL scanning (codeql-v7.yml). Errors are surfaced as typed values via checkResponse/createResponseError rather than swallowed, and naming is consistent across the generated service files (verb+resource, e.g. search_aggs_bucket_terms.go). No dedicated lint config (golangci-lint or similar) is present in the repo.
API Design
The library follows the fluent-builder convention common to Go API clients of its era: client.Search().Index(...).Query(...).From(...).Do(ctx), with one dedicated Go type per query/aggregation variant giving compile-time safety over hand-built JSON, plus extension points (Decoder, Retrier, custom httpClient) for advanced use. The tradeoff is real: getting full endpoint coverage requires one file per API surface (300+ files total), and the README itself now points newer projects to the official go-elasticsearch client, positioning this as a stable option for existing consumers rather than the recommended starting point for new ones.
Used by 3 apps in this directory
Formance Ledger
Invoicing Finance · Developer Tools · Databases
The programmable open source core ledger for fintech — build money-moving applications with atomic multi-posting transactions, account-based modeling, and Numscript, a built-in DSL for financial logic.
Nightingale
Monitoring
Open-source alerting engine that connects to any time-series or log data source and routes alarms to 20+ notification channels with AI-assisted triage.
temporal
Automation · Devops
Open-source durable execution platform that keeps mission-critical workflows running through any failure, automatically.