Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

An Elasticsearch REST API client for Rust

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
NotificationsYou must be signed in to change notification settings

elastic-rs/elastic

Repository files navigation

elastic is an efficient, modular API client forElasticsearch written inRust.The API is targeting the Elastic Stack7.x.

elastic provides strongly-typed documents and weakly-typed queries.

Quick reference:

Also check out the officialelasticsearch crate!

Stability

This crate is still quite unstable and is likely to continue to churn breaking releases over the near future with not-so-detailed changelogs.

If you run into any problems upgrading in your own open source projects feel free toopen up an issue and we'll give you a hand. The goal is definitely to offer a stable API eventually.

Build Status

PlatformChannelStatus (master)
Linux / macOSStable/NightlyBuild Status
WindowsNightlyBuild status

Documentation

VersionDocs
current (master)Documentation

Example

Addelastic to yourCargo.toml:

[dependencies]elastic ="0.21.0-pre.5"elastic_derive ="0.21.0-pre.5"serde_json ="1"

Create aSyncClient and start making requests:

#[macro_use]externcrate elastic_derive;#[macro_use]externcrate serde_json;externcrate elastic;use serde_json::Value;use elastic::prelude::*;// A reqwest HTTP client and default parameters.// The builder includes the base node url (http://localhost:9200).let client =SyncClient::builder().build()?;let query ="some query string";// A search request with a freeform body.let res = client.search::<Value>().index("_all").body(json!({"query":{"query_string":{"query": query}}})).send()?;// Iterate through the hits in the response.for hitin res.hits(){println!("{:?}", hit);}

elastic also offers anAsyncClient for use with thetokio asynchronous io stack.See theexamples folder for complete samples.

Building documents

Document mapping is derived at compile-time from yourPlain Old Rust Structures. Just add a#[derive(ElasticType)] attribute:

#[derive(ElasticType,Serialize,Deserialize)]structMyDocument{#[elastic(id)]pubid:String,pubtitle:String,pubtimestamp:Date<DefaultDateMapping<EpochMillis>>,pubcontent:Text<DefaultTextMapping>,}

And you can start usingMyDocument inClient request methods.

See thedocs for more details.

Alternatives

elastic.coreleased an official client,elasticsearch. 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.

Additionally, if you'd like to use a strongly-typed Query DSL builder seers-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.

Goals

To 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.

The REST API is covered by a simple inline JSON macro likeserde_json'sjson! 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 inDev Tools could just be copy+pasted into your Rust source.

The 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.

Support for Elastic's plugin products, likewatcher andgraph could be added as feature-gated modules as necessary.

License

Licensed under either of these:

About

An Elasticsearch REST API client for Rust

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Packages

No packages published

Contributors18

Languages


[8]ページ先頭

©2009-2025 Movatter.jp