1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
//! # OpenSearch DSL for Rust
//!
//! A high-level, strongly typed Domain Specific Language (DSL) for building OpenSearch queries in Rust.
//! This library provides a complete mapping to the OpenSearch Query DSL with compile-time type safety.
//!
//! *Based on the excellent [elasticsearch-dsl-rs](https://github.com/vinted/elasticsearch-dsl-rs)
//! project, adapted for OpenSearch.*
//!
//! ## Features
//!
//! - **🔒 Type Safety**: Strongly typed queries, aggregations, and responses with compile-time validation
//! - **🎯 Complete Coverage**: Full support for OpenSearch Query DSL including complex nested queries
//! - **📊 Rich Aggregations**: Support for all aggregation types with proper result parsing
//! - **🧩 Composable**: Build complex queries by composing smaller query components
//! - **⚡ Zero-Cost Abstractions**: Compiles to efficient JSON with no runtime overhead
//! - **🔌 Client Agnostic**: Works with any HTTP client, not tied to specific OpenSearch client libraries
//! - **📝 Auto-Generated JSON**: Automatically produces valid OpenSearch JSON from Rust code
//! - **🎨 Fluent API**: Chainable method calls for intuitive query building
//!
//! ## Installation
//!
//! Add to your `Cargo.toml`:
//!
//! ```toml
//! [dependencies]
//! opensearch-dsl = "0.3"
//! ```
//!
//! ## Quick Start
//!
//! ### Basic Search Query
//!
//! ```rust
//! use opensearch_dsl::*;
//!
//! let search = Search::new()
//! .source(false)
//! .from(0)
//! .size(10)
//! .query(Query::match_all())
//! .sort(vec![Sort::field("timestamp").desc()]);
//!
//! // Generates valid OpenSearch JSON
//! let json = serde_json::to_string(&search)?;
//! ```
//!
//! ### Complex Boolean Query
//!
//! ```rust
//! let search = Search::new()
//! .query(
//! Query::bool()
//! .must(vec![
//! Query::match_("title", "OpenSearch"),
//! Query::range("date").gte("2023-01-01")
//! ])
//! .should(vec![
//! Query::term("category", "tutorial"),
//! Query::term("featured", true)
//! ])
//! .filter(vec![
//! Query::term("status", "published")
//! ])
//! .minimum_should_match(1)
//! );
//! ```
//!
//! ### Aggregations
//!
//! ```rust
//! let search = Search::new()
//! .size(0)
//! .aggregations(vec![
//! ("categories", Aggregation::terms("category")),
//! ("monthly_sales",
//! Aggregation::date_histogram("date", "month")
//! .sub_aggregation("total_revenue", Aggregation::sum("price"))
//! )
//! ]);
//! ```
//!
//! ## Module Organization
//!
//! - [`search`] - Search queries and request building
//! - [`query`] - All query types (term, match, bool, etc.)
//! - [`aggregation`] - Aggregation types and builders
//! - [`sort`] - Sorting options and configurations
//! - [`types`] - Common types and utilities
//!
//! ## Integration with OpenSearch Client
//!
//! This DSL works seamlessly with the opensearch-client:
//!
//! ```rust
//! use opensearch_client::*;
//! use opensearch_dsl::*;
//!
//! let client = OsClient::new(/* configuration */);
//! let search = Search::new().query(Query::match_("title", "rust"));
//! let response = client.search(&search).index("articles").await?;
//! ```
//!
//! ## Examples
//!
//! For comprehensive examples including e-commerce search, log analytics, and time series analysis,
//! see the [examples directory](https://github.com/aparo/opensearch-client-rs/tree/main/examples).
//!
//! use opensearch_dsl::*;
//!
//! fn main() {
//! let query = Search::new()
//! .source(false)
//! .stats("statistics")
//! .from(0)
//! .size(30)
//! .query(
//! Query::bool()
//! .must(Query::multi_match(
//! ["title", "description"],
//! "you know, for search",
//! ))
//! .filter(Query::terms("tags", ["opensearch"]))
//! .should(Query::term("verified", true).boost(10)),
//! )
//! .aggregate(
//! "country_ids",
//! Aggregation::terms("country_id")
//! .aggregate("catalog_ids", Aggregation::terms("catalog_id"))
//! .aggregate("company_ids", Aggregation::terms("company_id"))
//! .aggregate(
//! "top1",
//! Aggregation::top_hits()
//! .size(1)
//! .sort(FieldSort::ascending("user_id")),
//! ),
//! )
//! .rescore(Rescore::new(Query::term("field", 1)).query_weight(1.2));
//! }
//! ```
//!
//! See examples for more.
//!
//! #### License
//!
//! <sup>
//! Licensed under either of <a href="LICENSE-APACHE">Apache License, Version
//! 2.0</a> or <a href="LICENSE-MIT">MIT license</a> at your option.
//! </sup>
extern crate pretty_assertions;
extern crate serde;
extern crate serde_json;
// Macro modules
// Crate modules
pub use *;
// Public modules
// Public re-exports
pub use ;