{"id":13484832,"url":"https://github.com/elastic/elasticsearch-rs","last_synced_at":"2026-06-02T16:31:11.636Z","repository":{"id":261099442,"uuid":"192310039","full_name":"elastic/elasticsearch-rs","owner":"elastic","description":"Official Elasticsearch Rust Client","archived":false,"fork":false,"pushed_at":"2025-04-30T08:08:25.000Z","size":4335,"stargazers_count":736,"open_issues_count":21,"forks_count":78,"subscribers_count":284,"default_branch":"main","last_synced_at":"2025-05-12T00:17:36.641Z","etag":null,"topics":["client","elasticsearch","elasticsearch-rs","rust"],"latest_commit_sha":null,"homepage":"https://www.elastic.co/guide/en/elasticsearch/client/rust-api/current/index.html","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/elastic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-06-17T08:51:36.000Z","updated_at":"2025-04-25T21:22:48.000Z","dependencies_parsed_at":"2024-11-04T17:55:22.453Z","dependency_job_id":"d2b18f3e-9d51-4abe-8d82-283d2c49c870","html_url":"https://github.com/elastic/elasticsearch-rs","commit_stats":{"total_commits":316,"total_committers":29,"mean_commits":10.89655172413793,"dds":0.4177215189873418,"last_synced_commit":"e6e2f0228ff9dae8487246c5c0b69270a34b057d"},"previous_names":["elastic/elasticsearch-rs"],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elastic%2Felasticsearch-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elastic%2Felasticsearch-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elastic%2Felasticsearch-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elastic%2Felasticsearch-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elastic","download_url":"https://codeload.github.com/elastic/elasticsearch-rs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253655514,"owners_count":21943063,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["client","elasticsearch","elasticsearch-rs","rust"],"created_at":"2024-07-31T17:01:35.491Z","updated_at":"2026-06-02T16:31:11.587Z","avatar_url":"https://github.com/elastic.png","language":"Rust","funding_links":[],"categories":["Rust","Clients \u0026 SDKs"],"sub_categories":[],"readme":"# elasticsearch \u0026emsp; [![Latest Version]][crates.io] [![Docs]][docs.rs] [![Apache-2 licensed]][license]\n\n[Latest Version]: https://img.shields.io/crates/v/elasticsearch.svg\n[crates.io]: https://crates.io/crates/elasticsearch\n[Docs]: https://docs.rs/elasticsearch/badge.svg\n[docs.rs]: https://docs.rs/elasticsearch\n[Apache-2 licensed]: https://img.shields.io/crates/l/elasticsearch.svg\n[license]: ./LICENSE.txt\n\nOfficial Rust Client for [Elasticsearch](https://github.com/elastic/elasticsearch).\n\nFull documentation is available at https://docs.rs/elasticsearch\n\nThe project is still very much a _work in progress_ and in an _alpha_ state;\ninput and contributions welcome!\n\n## Compatibility\n\nThe Elasticsearch Rust client is forward compatible; meaning that the client supports communicating with greater minor versions of Elasticsearch. Elasticsearch language clients are also backwards compatible with lesser supported minor Elasticsearch versions.\n\n## Features\n\nThe following are a list of Cargo features that can be enabled or disabled:\n\n- **native-tls** *(enabled by default)*: Enables TLS functionality provided by `native-tls`.\n- **rustls-tls**: Enables TLS functionality provided by `rustls`.\n- **beta-apis**: Enables beta APIs. Beta APIs are on track to become stable and permanent features. Use them with\n   caution because it is possible that breaking changes are made to these APIs in a minor version.\n- **experimental-apis**: Enables experimental APIs. Experimental APIs are just that - an experiment. An experimental\n  API might have breaking changes in any future version, or it might even be removed entirely. This feature also\n  enables `beta-apis`.\n\nAdditionally, this library also runs in Web Assembly runtimes that provide the [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API), like node.js and web browsers.\n\n## Getting started\n\nThe client exposes all Elasticsearch APIs as associated functions, either on\nthe root client, `Elasticsearch`, or on one of the _namespaced clients_, such as `Cat`, `Indices`, etc. The _namespaced clients_\nare based on the grouping of APIs within the [Elasticsearch](https://github.com/elastic/elasticsearch/tree/main/rest-api-spec) REST API specs from which much of the client is generated.\nAll API functions are `async` only, and can be `await`ed.\n\n### Installing\n\nAdd `elasticsearch` crate and version to Cargo.toml. Choose the version\nthat is compatible with the version of Elasticsearch you're using\n\n```toml\n[dependencies]\nelasticsearch = \"9.0.0-alpha.1\"\n```\n\nThe following _optional_ dependencies may also be useful to create requests and read responses\n\n```toml\nserde = \"~1\"\nserde_json = \"~1\"\n```\n\n----\n\n#### Async support with tokio\n\nThe client uses [`reqwest`](https://crates.io/crates/reqwest) to make HTTP calls, which internally uses\nthe [`tokio`](https://crates.io/crates/tokio) runtime for async support. As such, you may require to take a dependency on `tokio`\nin order to use the client. For example, in Cargo.toml, you may need the following dependency,\n\n```toml\ntokio = { version = \"*\", features = [\"full\"] }\n```\n\nand to attribute async main function with `#[tokio::main]`\n\n```rust,no_run\n#[tokio::main]\nasync fn main() -\u003e Result\u003c(), Box\u003cdyn std::error::Error\u003e\u003e {\n    // your code ...\n    Ok(())\n}\n```\n\nand attribute test functions with `#[tokio::test]`\n\n```rust,no_run\n#[tokio::test]\nasync fn my_test() -\u003e Result\u003c(), Box\u003cdyn std::error::Error\u003e\u003e {\n    // your code ...\n    Ok(())\n}\n```\n\n----\n\n### Create a client\n\nBuild a transport to make API requests to Elasticsearch using the `TransportBuilder`,\nwhich allows setting of proxies, authentication schemes, certificate validation, and\nother transport related settings.\n\nTo create a client to make API calls to Elasticsearch running on `https://localhost:9200`\n\n```rust,no_run\nuse elasticsearch::Elasticsearch;\n\nfn main() {\n    let client = Elasticsearch::default();\n}\n```\nAlternatively, you can create a client to make API calls against Elasticsearch running on a specific url\n\n```rust,no_run\nuse elasticsearch::{\n    Elasticsearch, Error,\n    http::transport::Transport\n};\n\nfn main() -\u003e Result\u003c(), Error\u003e {\n    let transport = Transport::single_node(\"https://example.com\")?;\n    let client = Elasticsearch::new(transport);\n    Ok(())\n}\n```\n\n If you're running against an Elasticsearch deployment in [Elastic Cloud](https://www.elastic.co/cloud/),\n a client can be created using a [Cloud ID](https://www.elastic.co/guide/en/cloud/current/ec-cloud-id.html)\n and credentials retrieved from the Cloud web console\n\n```rust,no_run\nuse elasticsearch::{\n    auth::Credentials,\n    Elasticsearch, Error,\n    http::transport::Transport,\n};\n\nfn main() -\u003e Result\u003c(), Error\u003e {\n    let cloud_id = \"cluster_name:Y2xvdWQtZW5kcG9pbnQuZXhhbXBsZSQzZGFkZjgyM2YwNTM4ODQ5N2VhNjg0MjM2ZDkxOGExYQ==\";\n    // can use other types of Credentials too, like Bearer or ApiKey\n    let credentials = Credentials::Basic(\"\u003cusername\u003e\".into(), \"\u003cpassword\u003e\".into());\n    let transport = Transport::cloud(cloud_id, credentials)?;\n    let client = Elasticsearch::new(transport);\n    Ok(())\n}\n```\n\n More control over how a `Transport` is built can be\n achieved using `TransportBuilder` to build a transport, and\n passing it to `Elasticsearch::new()` create a new instance of `Elasticsearch`\n\n```rust,no_run\nuse url::Url;\nuse elasticsearch::{\n    Error, Elasticsearch,\n    http::transport::{TransportBuilder,SingleNodeConnectionPool},\n};\n\nfn main() -\u003e Result\u003c(), Error\u003e {\n    let url = Url::parse(\"https://example.com\")?;\n    let conn_pool = SingleNodeConnectionPool::new(url);\n    let transport = TransportBuilder::new(conn_pool).disable_proxy().build()?;\n    let client = Elasticsearch::new(transport);\n    Ok(())\n}\n```\n\nYou can also configure the list of nodes of an Elasticsearch cluster using the `MultiNodeConnectionPool`, and the client will do a round-robin load balancing among those nodes. It can also periodically re-seed the list of nodes by querying the cluster.\n\n### Making API calls\n\nThe following will execute a `POST` request to `/_search?allow_no_indices=true` with\na JSON body of `{\"query\":{\"match_all\":{}}}`\n\n```rust,no_run\nuse elasticsearch::{Elasticsearch, Error, SearchParts};\nuse serde_json::{json, Value};\n\n#[tokio::main]\nasync fn main() -\u003e Result\u003c(), Box\u003cdyn std::error::Error\u003e\u003e {\n    let client = Elasticsearch::default();\n\n    // make a search API call\n    let search_response = client\n        .search(SearchParts::None)\n        .body(json!({\n            \"query\": {\n                \"match_all\": {}\n            }\n        }))\n        .allow_no_indices(true)\n        .send()\n        .await?;\n\n    // get the HTTP response status code\n    let status_code = search_response.status_code();\n\n    // read the response body. Consumes search_response\n    let response_body = search_response.json::\u003cValue\u003e().await?;\n\n    // read fields from the response body\n    let took = response_body[\"took\"].as_i64().unwrap();\n\n    Ok(())\n}\n```\n\nThe client provides functions on each API builder struct\nfor all query string parameters available for that API. APIs with multiple\nURI path variants, where some can contain parts parameters, are modelled as enums.\n\n`Elasticsearch` also has an async `send` function on the root that allows sending an\nAPI call to an endpoint not represented as an API function, for example, experimental\nand beta APIs\n\n```rust,no_run\nuse elasticsearch::{http::Method, Elasticsearch, Error, SearchParts};\nuse http::HeaderMap;\nuse serde_json::Value;\n\n#[tokio::main]\nasync fn main() -\u003e Result\u003c(), Box\u003cdyn std::error::Error\u003e\u003e {\n    let client = Elasticsearch::default();\n    let body = b\"{\\\"query\\\":{\\\"match_all\\\":{}}}\";\n    let response = client\n        .send(\n            Method::Post,\n            SearchParts::Index(\u0026[\"tweets\"]).url().as_ref(),\n            HeaderMap::new(),\n            Option::\u003c\u0026Value\u003e::None,\n            Some(body.as_ref()),\n            None,\n        )\n        .await?;\n    Ok(())\n}\n```\n\n## License\n\nThis is free software, licensed under [The Apache License Version 2.0.](LICENSE.txt).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felastic%2Felasticsearch-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felastic%2Felasticsearch-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felastic%2Felasticsearch-rs/lists"}