https://github.com/elastic/go-elasticsearch
The official Go client for Elasticsearch
https://github.com/elastic/go-elasticsearch
client elasticsearch go golang
Last synced: about 1 month ago
JSON representation
The official Go client for Elasticsearch
- Host: GitHub
- URL: https://github.com/elastic/go-elasticsearch
- Owner: elastic
- License: apache-2.0
- Created: 2017-03-27T17:56:15.000Z (about 8 years ago)
- Default Branch: main
- Last Pushed: 2025-04-30T14:15:48.000Z (about 2 months ago)
- Last Synced: 2025-05-05T17:21:22.843Z (about 2 months ago)
- Topics: client, elasticsearch, go, golang
- Language: Go
- Homepage: https://github.com/elastic/go-elasticsearch#go-elasticsearch
- Size: 70.5 MB
- Stars: 5,865
- Watchers: 373
- Forks: 626
- Open Issues: 77
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- awesome-go - go-elasticsearch - Official Elasticsearch client for Go. (Database Drivers / Search and Analytic Databases)
- awesome-elastic-resources - Link
- awesome-starts - elastic/go-elasticsearch - The official Go client for Elasticsearch (Go)
- go-awesome - go-elasticsearch - Official ES Client (Open source library / Search Recommendations)
- awesome-list - go-elasticsearch - The official Go client for Elasticsearch (Data Management & Processing / Database & Cloud Management)
- awesome-golang-repositories - go-elasticsearch
- awesome-go-extra - go-elasticsearch - 03-27T17:56:15Z|2022-08-24T16:13:45Z| (Generators / Search and Analytic Databases)
- awesome-go - go-elasticsearch - Official Elasticsearch client for Go. Stars:`5.9K`. (Database Drivers / Search and Analytic Databases)
- StarryDivineSky - elastic/go-elasticsearch - elasticsearch 是 Elasticsearch 官方提供的 Go 语言客户端。它提供了一系列 API,方便 Go 开发者与 Elasticsearch 集群进行交互,包括索引、搜索、更新和删除文档等操作。该客户端的设计目标是高性能、易用性和可扩展性,支持 Elasticsearch 的所有功能,并提供丰富的配置选项。它使用 Elasticsearch 的 REST API 进行通信,通过 HTTP 请求发送和接收 JSON 数据。该客户端支持连接到单个 Elasticsearch 节点或集群,并具有自动节点发现和故障转移功能。它还提供了一些高级功能,如批量操作、滚动搜索和聚合查询。开发者可以通过简单的 Go 代码,轻松地将 Elasticsearch 集成到他们的应用程序中,实现强大的搜索和分析功能。go-elasticsearch 遵循 Elasticsearch 的版本更新,并提供详细的文档和示例,帮助开发者快速上手。它是一个稳定可靠的 Elasticsearch Go 语言客户端,适用于各种规模的项目。 (数据搜索引擎 / 资源传输下载)
README
# go-elasticsearch
The official Go client for [Elasticsearch](https://www.elastic.co/products/elasticsearch).
**[Download the latest version of Elasticsearch](https://www.elastic.co/downloads/elasticsearch)**
or
**[sign-up](https://cloud.elastic.co/registration?elektra=en-ess-sign-up-page)**
**for a free trial of Elastic Cloud**.[](https://pkg.go.dev/github.com/elastic/go-elasticsearch/v9)
[](https://goreportcard.com/report/github.com/elastic/go-elasticsearch)
[](https://codecov.io/gh/elastic/go-elasticsearch?branch=main)
[](https://github.com/elastic/go-elasticsearch/actions?query=branch%3Amain)
[](https://github.com/elastic/go-elasticsearch/actions?query=branch%3Amain)
[](https://github.com/elastic/go-elasticsearch/actions?query=branch%3Amain)
[](https://github.com/elastic/go-elasticsearch/actions?query=branch%3Amain)## Compatibility
### Go
Starting from version `8.12.0`, this library follow the Go language [policy](https://go.dev/doc/devel/release#policy). Each major Go release is supported until there are two newer major releases. For example, Go 1.5 was supported until the Go 1.7 release, and Go 1.6 was supported until the Go 1.8 release.
### Elasticsearch
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.When using Go modules, include the version in the import path, and specify either an explicit version or a branch:
require github.com/elastic/go-elasticsearch/v9 v9.x.x
require github.com/elastic/go-elasticsearch/v8 v8.x.xIt's possible to use multiple versions of the client in a single project:
// go.mod
github.com/elastic/go-elasticsearch/v8 v8.18.0
github.com/elastic/go-elasticsearch/v9 v9.0.0// main.go
import (
elasticsearch7 "github.com/elastic/go-elasticsearch/v8"
elasticsearch8 "github.com/elastic/go-elasticsearch/v9"
)
// ...
es8, _ := elasticsearch7.NewDefaultClient()
es9, _ := elasticsearch8.NewDefaultClient()The `main` branch of the client is compatible with the current `master` branch of Elasticsearch.
## Installation
Refer to the [Installation section](https://www.elastic.co/guide/en/elasticsearch/client/go-api/current/getting-started-go.html#_installation)
of the getting started documentation.## Connecting
Refer to the [Connecting section](https://www.elastic.co/guide/en/elasticsearch/client/go-api/current/getting-started-go.html#_connecting)
of the getting started documentation.## Operations
* [Creating an index](https://www.elastic.co/guide/en/elasticsearch/client/go-api/current/getting-started-go.html#_creating_an_index)
* [Indexing documents](https://www.elastic.co/guide/en/elasticsearch/client/go-api/current/getting-started-go.html#_indexing_documents)
* [Getting documents](https://www.elastic.co/guide/en/elasticsearch/client/go-api/current/getting-started-go.html#_getting_documents)
* [Searching documents](https://www.elastic.co/guide/en/elasticsearch/client/go-api/current/getting-started-go.html#_searching_documents)
* [Updating documents](https://www.elastic.co/guide/en/elasticsearch/client/go-api/current/getting-started-go.html#_updating_documents)
* [Deleting documents](https://www.elastic.co/guide/en/elasticsearch/client/go-api/current/getting-started-go.html#_deleting_documents)
* [Deleting an index](https://www.elastic.co/guide/en/elasticsearch/client/go-api/current/getting-started-go.html#_deleting_an_index)## Helpers
The `esutil` package provides convenience helpers for working with the client. At the moment, it provides the `esutil.JSONReader()` and the `esutil.BulkIndexer` helpers.
## Examples
The **[`_examples`](./_examples)** folder contains a number of recipes and comprehensive examples to get you started with the client, including configuration and customization of the client, using a custom certificate authority (CA) for security (TLS), mocking the transport for unit tests, embedding the client in a custom type, building queries, performing requests individually and in bulk, and parsing the responses.
## License
This software is licensed under the [Apache 2 license](./LICENSE). See [NOTICE](./NOTICE).