elasticsearch_dsl/lib.rs
1//! # Strongly typed Elasticsearch DSL written in Rust
2//!
3//! This is an unofficial library and doesn't yet support all the DSL, it's still work in progress.
4//!
5//! ## Features
6//!
7//! - Strongly typed queries
8//! - Strongly typed aggregations
9//! - Automatically skips empty queries making DSL pleasant to use
10//! - Crate doesn't depend on [elasticsearch-rs](https://github.com/elastic/elasticsearch-rs) and can be used as a standalone library with any HTTP client to call Elasticsearch
11//!
12//! ## Installation
13//!
14//! Add `elasticsearch-dsl` crate and version to Cargo.toml
15//!
16//! ```toml
17//! [dependencies]
18//! elasticsearch-dsl = "0.2"
19//! ```
20//!
21//! ## Documentation
22//!
23//! Documentation for the library is available on [docs.rs](https://docs.rs/elasticsearch-dsl)
24//!
25//! ## Quick start
26//!
27//! ```rust
28//! use elasticsearch_dsl::*;
29//!
30//! let query = Search::new()
31//! .source(false)
32//! .stats("statistics")
33//! .from(0)
34//! .size(30)
35//! .query(
36//! Query::bool()
37//! .must(Query::multi_match(
38//! ["title", "description"],
39//! "you know, for search",
40//! ))
41//! .filter(Query::terms("tags", ["elasticsearch"]))
42//! .should(Query::term("verified", true).boost(10)),
43//! )
44//! .aggregate(
45//! "country_ids",
46//! Aggregation::terms("country_id")
47//! .aggregate("catalog_ids", Aggregation::terms("catalog_id"))
48//! .aggregate("company_ids", Aggregation::terms("company_id"))
49//! .aggregate(
50//! "top1",
51//! Aggregation::top_hits()
52//! .size(1)
53//! .sort(FieldSort::ascending("user_id")),
54//! ),
55//! ).rescore(Rescore::new(Query::term("field", 1)).query_weight(1.2));
56//! ```
57//!
58//! See examples for more.
59//!
60//! #### License
61//!
62//! <sup>
63//! Licensed under either of <a href="LICENSE-APACHE">Apache License, Version
64//! 2.0</a> or <a href="LICENSE-MIT">MIT license</a> at your option.
65//! </sup>
66#![doc(
67 html_logo_url = "https://play-lh.googleusercontent.com/VvtT2Dvf_oOC3DL4c2i5hfNvwIqzdU2apScRMlmeRW10Yf-vJXnXqAjdNWE9KW5YvK0"
68)]
69#![deny(
70 bad_style,
71 dead_code,
72 deprecated,
73 improper_ctypes,
74 missing_debug_implementations,
75 missing_docs,
76 non_shorthand_field_patterns,
77 no_mangle_generic_items,
78 overflowing_literals,
79 path_statements,
80 patterns_in_fns_without_body,
81 trivial_casts,
82 trivial_numeric_casts,
83 unconditional_recursion,
84 unknown_lints,
85 unreachable_code,
86 unreachable_pub,
87 unused,
88 unused_allocation,
89 unused_comparisons,
90 unused_extern_crates,
91 unused_import_braces,
92 unused_mut,
93 unused_parens,
94 unused_qualifications,
95 unused_results,
96 warnings,
97 while_true
98)]
99#![allow(ambiguous_glob_reexports)]
100
101#[cfg(test)]
102#[macro_use]
103extern crate pretty_assertions;
104
105#[macro_use]
106extern crate serde;
107
108#[cfg(test)]
109#[macro_use]
110extern crate serde_json;
111
112// Macro modules
113#[macro_use]
114mod macros;
115mod types;
116
117// Crate modules
118#[macro_use]
119pub(crate) mod util;
120pub(crate) use self::types::*;
121
122// Public modules
123pub mod analyze;
124pub mod search;
125
126// Public re-exports
127pub use self::analyze::*;
128pub use self::search::*;