{"id":13595628,"url":"https://github.com/elastic-rs/elastic","last_synced_at":"2025-05-07T04:27:42.094Z","repository":{"id":57623784,"uuid":"47872680","full_name":"elastic-rs/elastic","owner":"elastic-rs","description":"An Elasticsearch REST API client for Rust","archived":false,"fork":false,"pushed_at":"2020-06-17T21:01:43.000Z","size":24792,"stargazers_count":254,"open_issues_count":35,"forks_count":39,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-28T11:11:45.112Z","etag":null,"topics":["elasticsearch","http-client","rust"],"latest_commit_sha":null,"homepage":"","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-rs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"contributing/getting-started.md","funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-12-12T09:45:23.000Z","updated_at":"2025-02-07T10:26:14.000Z","dependencies_parsed_at":"2022-09-26T20:10:48.022Z","dependency_job_id":null,"html_url":"https://github.com/elastic-rs/elastic","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elastic-rs%2Felastic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elastic-rs%2Felastic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elastic-rs%2Felastic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elastic-rs%2Felastic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elastic-rs","download_url":"https://codeload.github.com/elastic-rs/elastic/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251422599,"owners_count":21587018,"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":["elasticsearch","http-client","rust"],"created_at":"2024-08-01T16:01:53.998Z","updated_at":"2025-05-07T04:27:42.064Z","avatar_url":"https://github.com/elastic-rs.png","language":"Rust","readme":"# [`elastic`](https://docs.rs/elastic/*/elastic/) [![Latest Version](https://img.shields.io/crates/v/elastic.svg)](https://crates.io/crates/elastic) [![Gitter](https://img.shields.io/gitter/room/nwjs/nw.js.svg)](https://gitter.im/elastic-rs/Lobby)\n\n`elastic` is an efficient, modular API client for [Elasticsearch](https://github.com/elastic/elasticsearch) written in [Rust](https://www.rust-lang.org).\nThe API is targeting the Elastic Stack `7.x`.\n\n`elastic` provides strongly-typed documents and weakly-typed queries.\n\nQuick reference:\n\n- [simple examples](https://github.com/elastic-rs/elastic/tree/master/src/elastic/examples)\n- [example apps](https://github.com/elastic-rs/elastic/tree/master/examples)\n\nAlso check out the official [**elasticsearch**](https://github.com/elastic/elasticsearch-rs) crate! \n\n## Stability\n\nThis crate is still quite unstable and is likely to continue to churn breaking releases over the near future with not-so-detailed changelogs.\n\nIf you run into any problems upgrading in your own open source projects feel free to [open up an issue](https://github.com/elastic-rs/elastic/issues) and we'll give you a hand. The goal is definitely to offer a stable API eventually.\n\n## Build Status\nPlatform  | Channel | Status (`master`)\n------------- | ------------- | -------------\nLinux / macOS  | Stable/Nightly | [![Build Status](https://travis-ci.org/elastic-rs/elastic.svg?branch=master)](https://travis-ci.org/elastic-rs/elastic)\nWindows  | Nightly | [![Build status](https://ci.appveyor.com/api/projects/status/csa78tcumdpnbur2?svg=true)](https://ci.appveyor.com/project/KodrAus/elastic)\n## Documentation\n\nVersion                | Docs\n---------------------- | -------------\ncurrent (`master`)     | [![Documentation](https://img.shields.io/badge/docs-rustdoc-blue.svg)](https://docs.rs/elastic/*/elastic/)\n\n## Example\n\nAdd `elastic` to your `Cargo.toml`:\n\n```toml\n[dependencies]\nelastic = \"0.21.0-pre.5\"\nelastic_derive = \"0.21.0-pre.5\"\nserde_json = \"1\"\n```\n\nCreate a `SyncClient` and start making requests:\n\n```rust\n#[macro_use]\nextern crate elastic_derive;\n#[macro_use]\nextern crate serde_json;\nextern crate elastic;\n\nuse serde_json::Value;\nuse elastic::prelude::*;\n\n// A reqwest HTTP client and default parameters.\n// The builder includes the base node url (http://localhost:9200).\nlet client = SyncClient::builder().build()?;\n\nlet query = \"some query string\";\n\n// A search request with a freeform body.\nlet res = client.search::\u003cValue\u003e()\n                .index(\"_all\")\n                .body(json!({\n                    \"query\": {\n                        \"query_string\": {\n                            \"query\": query\n                        }\n                    }\n                }))\n                .send()?;\n\n// Iterate through the hits in the response.\nfor hit in res.hits() {\n    println!(\"{:?}\", hit);\n}\n```\n\n`elastic` also offers an `AsyncClient` for use with the `tokio` asynchronous io stack.\nSee the [examples](https://github.com/elastic-rs/elastic/tree/master/examples) folder for complete samples.\n\n### Building documents\n\nDocument mapping is derived at compile-time from your _Plain Old Rust Structures_. Just add a `#[derive(ElasticType)]` attribute:\n\n```rust\n#[derive(ElasticType, Serialize, Deserialize)]\nstruct MyDocument {\n\t#[elastic(id)]\n\tpub id: String,\n\tpub title: String,\n\tpub timestamp: Date\u003cDefaultDateMapping\u003cEpochMillis\u003e\u003e,\n\tpub content: Text\u003cDefaultTextMapping\u003e,\n}\n```\n\nAnd you can start using `MyDocument` in `Client` request methods.\n\nSee the [docs](https://docs.rs/elastic/*/elastic/types/index.html) for more details.\n\n## Alternatives\n\n[elastic.co](https://www.elastic.co) [released](https://www.elastic.co/blog/rust-client-for-elasticsearch-alpha-release) an official client, [elasticsearch](https://github.com/elastic/elasticsearch-rs). Although it is still in an alpha stage (as of 2020-02-10), it is very comprehensive and generates most of its code from the official REST API specifications.\n\nAdditionally, if you'd like to use a strongly-typed Query DSL builder see [`rs-es`](https://github.com/benashford/rs-es). This client does the hard work of providing an idiomatic Rust API for interacting with Elasticsearch. It has the advantage of letting you know your queries will parse at compile-time instead of runtime.\n\n## Goals\n\nTo provide a full-featured and efficient Elasticsearch client for Rust over asynchronous io. Rust gives us a lot of tools for building super-performant but highly accessible libraries, which we aim to continue. `elastic` is aimed at people who need to work with Elasticsearch and are considering using Rust, as well as users that are already using Rust. We want to offer a solution to interacting with Elasticsearch that's compelling from both within and outside the Rust ecosystem.\n\nThe REST API is covered by a simple inline JSON macro like `serde_json`'s [`json!`](https://docs.serde.rs/serde_json/macro.json.html) so it's always possible to build any query. This means you don't need to learn another API for interacting with Elasticsearch; queries mocked in [Dev Tools](https://www.elastic.co/blog/found-sense-a-cool-json-aware-interface-to-elasticsearch) could just be copy+pasted into your Rust source.\n\nThe core focus of this project is on strong typing over your document types and query responses in Elasticsearch, rather than trying to map the entire Query DSL.\n\nSupport for Elastic's plugin products, like `watcher` and `graph` could be added as feature-gated modules as necessary.\n\n## License\n\nLicensed under either of these:\n \n- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://apache.org/licenses/LICENSE-2.0)\n- MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)\n","funding_links":[],"categories":["Rust","Libraries","库 Libraries"],"sub_categories":["Database","数据库 Database"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felastic-rs%2Felastic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felastic-rs%2Felastic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felastic-rs%2Felastic/lists"}