go-elasticsearch
AGENTS.md6.1k starsChanged 8 months agoApache-2.0View on GitHub
CLAUDE.md is a symlink to this file — they are the same file, do not update both. Official Elasticsearch Go client. Module: github.com/elastic/go-elasticsearch/v9. This is a public library with external consumers. Maintain backwards compatibility: PRs are squash-merged into a single commit when landing on main or a version branch. Because of this, each PR should represent one distinct, self-contained change — a single feature, bug fix, or refactor. Mixing unrelated changes in one PR means they become inseparable in history,…
Trending
Quiet since December.thin dataabout the whole repository
Who's talking about elastic/go-elasticsearch
- olivere/elastic“Announcement: Future directions (updated on 2022-07-22)”GitHub · Sep 22, 2021 · 49 reactions
- A Hacker News story“New Go Client for Elasticsearch”Hacker News · Feb 9, 2019 · 15 points
- elastic/kibana“Go-Kibana - Official Kibana API client for Golang”GitHub · Mar 3, 2021 · 9 reactions
- DataDog/dd-trace-go“contrib/elastic/go-elasticsearch: Add support for github.com/elastic/go-elasticsearch”GitHub · Jan 28, 2021 · 4 reactions
- gojp/goreportcard“could not get latest module version: no matching versions for query "latest"”GitHub · Aug 1, 2024 · 3 reactions
The biggest 5 of 10 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 10
Talked about on GitHub and Hacker News (10 times).
On GitHub · 9
- Sep 22, 2021Announcement: Future directions (updated on 2022-07-22) — olivere/elastic49 reactions · 11 comments
- Mar 3, 2021Go-Kibana - Official Kibana API client for Golang — elastic/kibana9 reactions · 4 comments
- Jan 28, 2021contrib/elastic/go-elasticsearch: Add support for github.com/elastic/go-elasticsearch — DataDog/dd-trace-go4 reactions · 5 comments
- Aug 1, 2024could not get latest module version: no matching versions for query "latest" — gojp/goreportcard3 reactions · 4 comments
- Apr 29, 2024Add elastic 8 support via `github.com/elastic/go-elasticsearch/v8` — go-gitea/gitea3 reactions · 11 comments
4 more on GitHub
- Jan 28, 2020Fix the "slices" parameter for the Delete By Query API in the REST specification — elastic/elasticsearch3 reactions · 3 comments
- Dec 4, 2025Add clients to updatecli automation — elastic/docs-builder2 reactions · 3 comments
- Nov 27, 2025add support to elasticsearch/v9 — redpanda-data/connect2 reactions · 3 comments
- Apr 28, 2024Elasticsearch 8 support — go-gitea/gitea2 reactions · 3 comments
On Hacker News · 1
- Feb 9, 2019New Go Client for Elasticsearch15 points
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repositoryOne other file it gives its agents.
- CLAUDE.mdCLAUDE.md
The file
We split this AGENTS.md into the rules it gives an agent
11 rules. About 0 are common, 9 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈9
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 12
Do NOT remove or rename exported types, functions, methods, or fields.
- Distinctive: line 13
Do NOT change function/method signatures (parameter types, return types, receiver types).
- Distinctive: line 14
Do NOT change the behavior of existing public APIs in a breaking way.
- Distinctive: line 16
If a deprecation is needed, add a new API and mark the old one deprecated via godoc comment.
- Distinctive: line 34
All Go files must include the Apache 2.0 license header:
- Distinctive: line 56
All exported types and functions must have godoc comments.
- Very specific: line 57
Before finishing, always run: make lint && make test-unit.
- Distinctive: line 73
Keep each PR focused on a single logical change with a clear purpose.
- Distinctive: line 74
Avoid bundling unrelated fixes or refactors into a feature PR — send them separately.
- Distinctive: line 75
Prefer multiple small PRs over one large PR, even if they land in quick succession.
- Very specific: line 118
When modifying dependencies, use make go-mod-tidy-all to tidy all modules.
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AGENTS.md
This file provides guidance to AI coding agents working with code in this repository. CLAUDE.md is a symlink to this file — they are the same file, do not update both.
Official Elasticsearch Go client. Module: github.com/elastic/go-elasticsearch/v9.
Backwards Compatibility
This is a public library with external consumers. Maintain backwards compatibility:
- Do NOT remove or rename exported types, functions, methods, or fields.
- Do NOT change function/method signatures (parameter types, return types, receiver types).
- Do NOT change the behavior of existing public APIs in a breaking way.
- Adding new exported symbols, new fields to config structs, or new methods is fine.
- If a deprecation is needed, add a new API and mark the old one deprecated via godoc comment; do not remove it.
Commands
make test-unit # unit tests
go test -v -run TestName ./pkg # single test
make test-integ # integration tests (requires ES)
make test-bench # benchmarks
make lint # go vet
make go-mod-tidy-all # tidy all modules
make cluster # start ES in Docker
make gen-api # regenerate esapi/ from specsKey Rules
- DO NOT manually edit files in
esapi/ortypedapi/— they are generated. Usemake gen-api. - All Go files must include the Apache 2.0 license header:
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.- Integration tests use build tag
//go:build integration, unit tests use//go:build !integration. - All exported types and functions must have godoc comments.
- Before finishing, always run:
make lint && make test-unit.
Regeneration
make gen-apiregeneratesesapi/from the REST spec. Commit only this output in regeneration PRs.make gen-testsregenerates the YAML-driven tests inesapi/test/andinternal/build/cmd/generate/commands/gentests/api_registry.gen.go. This runs in Buildkite CI; do not commit its output locally.- Regenerating after a generator fix or long gap will include spec drift (new endpoints, reworded descriptions, additive fields). Mention it in the PR body alongside the motivating change.
make download-specsuses the Makefile's default version. Override withELASTICSEARCH_BUILD_VERSION=X.Y.Z make download-specswhen regenerating a version branch from a checkout whose default targets a different version.
Commits and Pull Requests
PRs are squash-merged into a single commit when landing on main or a version branch. Because of this, each PR should represent one distinct, self-contained change — a single feature, bug fix, or refactor. Mixing unrelated changes in one PR means they become inseparable in history, making reviews harder and reverts riskier (reverting one change would also revert the unrelated ones).
When planning work:
- Break larger features into a sequence of small, independently mergeable PRs.
- Keep each PR focused on a single logical change with a clear purpose.
- Avoid bundling unrelated fixes or refactors into a feature PR — send them separately.
- Prefer multiple small PRs over one large PR, even if they land in quick succession.
Breaking changes
Commits containing breaking API changes need a BREAKING-CHANGE: footer (preceded by a blank line) on a fix: or feat: commit. release-please reads the footer from the squash-merged commit to flag the release accordingly. Do not mark a breaking change as chore: or refactor:.
Architecture
Two Client Types
Both clients share BaseClient (transport, product-check, meta headers) but expose different API surfaces:
Client(functional API) — embeds*esapi.API. Created withNewClient(Config)orNew(opts ...Option). Each API endpoint is a function-type field on theAPIstruct that accepts functional options (func(*SearchRequest)).TypedClient(typed API) — embeds*typedapi.MethodAPI. Created withNewTypedClient(Config)orNewTyped(opts ...Option). Each endpoint returns a fluent builder struct with typed request/response structs.
Package Layout
| Path | Description |
elasticsearch.go | Client construction, Config, transport setup |
options.go | Functional-options API (New(opts ...Option)) |
esapi/ | Auto-generated flat API methods (DO NOT EDIT) |
typedapi/ | Auto-generated typed API builders (DO NOT EDIT) |
esutil/ | Utility helpers (BulkIndexer, JSONReader) |
internal/build/ | Code generator (cobra CLI, separate go.mod) |
internal/testing/ | Integration/e2e tests (separate go.mod) |
internal/version/ | Client version constant |
Generated Code Patterns
esapi — each endpoint file (api.<name>.go) contains: a function-type alias (e.g. type Search func(...) (*Response, error)), a SearchRequest struct with all params, a Do(ctx, transport) method that builds the HTTP request, and WithXxx option functions.
typedapi — each endpoint is a separate package (typedapi/core/search/). Contains a builder struct with fluent setters, HttpRequest(ctx) to build the request, Perform(ctx) for raw response, and Do(ctx) for typed JSON-decoded response. Types live in typedapi/types/ (~2000 generated files).
Multi-Module Structure
The repo contains multiple Go modules (each with its own go.mod):
- Root: main client library
internal/build/:esapicode generator (usesreplacedirective to reference root)internal/testing/: integration testsesapi/test/: generated YAML-driven API tests_examples/*/: each example is a standalone module
When modifying dependencies, use make go-mod-tidy-all to tidy all modules.
Instrumentation & Interceptors
Two extensibility points, both from elastic-transport-go:
- Instrumentation: lifecycle hooks per API call (Start, BeforeRequest, AfterRequest, RecordError, Close). Enabled via
Config.Instrumentation. OTel adapter:NewOpenTelemetryInstrumentation(provider, captureSearchBody). - Interceptors:
[]InterceptorFuncmiddleware on the transport's RoundTripper. Set once at construction viaConfig.Interceptors. Applied left-to-right (outermost first).
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

