elastic/go-elasticsearch

GitHub: elastic/go-elasticsearch

Elastic 官方推出的 Elasticsearch Go 客户端,帮助 Go 开发者在应用中高效地与 Elasticsearch 集群进行交互。

Stars: 6059 | Forks: 644

# go-elasticsearch [Elasticsearch](https://www.elastic.co/products/elasticsearch) 的官方 Go 客户端。 **[下载最新版本的 Elasticsearch](https://www.elastic.co/downloads/elasticsearch)** 或者 **[注册](https://cloud.elastic.co/registration?elektra=en-ess-sign-up-page)** **免费试用 Elastic Cloud**。 [![Go Reference](https://pkg.go.dev/badge/github.com/elastic/go-elasticsearch/v9.svg)](https://pkg.go.dev/github.com/elastic/go-elasticsearch/v9) [![Go Report Card](https://goreportcard.com/badge/github.com/elastic/go-elasticsearch)](https://goreportcard.com/report/github.com/elastic/go-elasticsearch) [![Build](https://static.pigsec.cn/wp-content/uploads/repos/cas/3b/3b39c55110f11a97d10cda63d1c1193c1b78ee3e26d559adaea16b191fc65e8a.svg)](https://github.com/elastic/go-elasticsearch/actions/workflows/build.yml?query=branch%3Amain) [![Unit](https://static.pigsec.cn/wp-content/uploads/repos/cas/ea/eae37a5b6ec4eb882a7b495e83341dd4d4d8add5e4cd7f6035a0481734e16245.svg)](https://github.com/elastic/go-elasticsearch/actions/workflows/test-unit.yml?query=branch%3Amain) [![Integration](https://static.pigsec.cn/wp-content/uploads/repos/cas/92/920dc6a332969520cddd8f305e5d752d68a07e8bc5c421ff26e0c8a78858c670.svg)](https://github.com/elastic/go-elasticsearch/actions/workflows/test-integration.yml?query=branch%3Amain) [![API](https://static.pigsec.cn/wp-content/uploads/repos/cas/cd/cdb14df2a64a5c1c8931273fd2a86aa31cbbb43c99da20e54544f2723b9f22f9.svg)](https://github.com/elastic/go-elasticsearch/actions/workflows/test-api.yml?query=branch%3Amain) [![Lint](https://static.pigsec.cn/wp-content/uploads/repos/cas/15/15e9e38379783188cff60c52dc1a4956f07be3c00c7a8bad969dd41a89434ae0.svg)](https://github.com/elastic/go-elasticsearch/actions/workflows/lint.yml) ## 文档 在 [elastic.co](https://www.elastic.co/docs/reference/elasticsearch/clients/go) 查看完整的参考文档: - [入门指南](https://www.elastic.co/docs/reference/elasticsearch/clients/go/getting-started) - [配置](https://www.elastic.co/docs/reference/elasticsearch/clients/go/configuration) - [使用 API](https://www.elastic.co/docs/reference/elasticsearch/clients/go/using-the-api)(底层和强类型) - [Typed API](https://www.elastic.co/docs/reference/elasticsearch/clients/go/typed-api) 和 [esdsl 构建器](https://www.elastic.co/docs/reference/elasticsearch/clients/go/typed-api/esdsl) - [高级主题](https://www.elastic.co/docs/reference/elasticsearch/clients/go/advanced)(拦截器、可观测性) Go 包参考文档位于 [pkg.go.dev](https://pkg.go.dev/github.com/elastic/go-elasticsearch/v9)。 ## 兼容性 ### Go 从 `8.12.0` 版本开始,本库遵循 Go 语言的[发布策略](https://go.dev/doc/devel/release#policy)。每个主要的 Go 版本都会得到支持,直到出现两个更新的主要版本。例如,Go 1.5 一直得到支持直到 Go 1.7 发布,而 Go 1.6 一直得到支持直到 Go 1.8 发布。 ### Elasticsearch 语言客户端是向前兼容的;这意味着客户端支持与更高或相等的次要版本的 Elasticsearch 进行通信。 Elasticsearch 语言客户端仅对默认发行版提供向后兼容,且不作任何保证。 使用 Go 模块时,请在导入路径中包含版本号,并指定明确的版本或分支: ``` require github.com/elastic/go-elasticsearch/v9 v9.x.x require github.com/elastic/go-elasticsearch/v8 v8.x.x ``` 可以在单个项目中使用多个版本的客户端: ``` // go.mod github.com/elastic/go-elasticsearch/v8 v8.18.0 github.com/elastic/go-elasticsearch/v9 v9.0.0 // main.go import ( elasticsearch8 "github.com/elastic/go-elasticsearch/v8" elasticsearch9 "github.com/elastic/go-elasticsearch/v9" ) // ... es8, _ := elasticsearch8.New() es9, _ := elasticsearch9.New() ``` 客户端的 `main` 分支与 Elasticsearch 当前的 `master` 分支兼容。 ## 安装 请参阅文档的[安装](https://www.elastic.co/docs/reference/elasticsearch/clients/go/installation) 页面。 ## 连接 请参阅文档的[连接](https://www.elastic.co/docs/reference/elasticsearch/clients/go/connecting) 页面。 ## 操作 - [创建索引](https://www.elastic.co/docs/reference/elasticsearch/clients/go/using-the-api/crud-operations) - [索引文档](https://www.elastic.co/docs/reference/elasticsearch/clients/go/using-the-api/crud-operations) - [获取文档](https://www.elastic.co/docs/reference/elasticsearch/clients/go/using-the-api/crud-operations) - [搜索文档](https://www.elastic.co/docs/reference/elasticsearch/clients/go/using-the-api/searching) - [更新文档](https://www.elastic.co/docs/reference/elasticsearch/clients/go/using-the-api/crud-operations) - [删除文档](https://www.elastic.co/docs/reference/elasticsearch/clients/go/using-the-api/crud-operations) - [删除索引](https://www.elastic.co/docs/reference/elasticsearch/clients/go/using-the-api/crud-operations) ## 辅助工具 `esutil` 包提供了使用客户端的便捷辅助工具。目前,它提供了 `esutil.JSONReader()` 和 [`esutil.BulkIndexer`](https://www.elastic.co/docs/reference/elasticsearch/clients/go/using-the-api/bulk-indexing) 辅助工具。 ## 示例 **[`_examples`](./_examples)** 文件夹包含许多配方和详尽的示例,可帮助您开始使用客户端, 包括客户端的配置和自定义、使用自定义证书颁发机构 (CA) 进行安全保护 (TLS)、 为单元测试模拟传输层、将客户端嵌入到自定义类型中、构建查询、单独和批量执行请求,以及解析响应。 ## 许可证 本软件根据 [Apache 2 许可证](./LICENSE) 授权。详见 [NOTICE](./NOTICE)。
标签:Elasticsearch, EVTX分析, Go, Ruby工具, 官方客户端, 开发库, 搜索引擎, 数据库, 日志审计