ElasticQueryBuilder is a query builder designed to easily build ElasticSearch related DSLs.
```toml
[dependencies] elastic-query-builder ="0.1" ```
rust
fn main() {
let mut mapping = MappingBuilder::new();
mapping
.add_property("title", KeywordFieldType::new())
.add_property("content", TextFieldType::new());
assert_eq!(
mapping.build().to_string(),
r#"{"mappings":{"properties":{"content":{"type":"text"},"title":{"type":"keyword"}}}}"#
);
}
rust
fn main() {
let mut query = QueryBuilder::new();
query.set_query(MatchQuery::new("field", "value"));
query.set_from(10);
query.set_size(100);
let value_json = query.build();
}
rust
fn main() {
let mut query = QueryBuilder::new();
let mut bool = BoolQuery::new();
bool.add_must(MatchQuery::new("field1", "value"));
bool.add_must_not(MatchQuery::new("field2", "value"));
bool.add_should(MatchQuery::new("field3", "value"));
query.set_query(bool);
}
rust
fn main() {
let mut query = QueryBuilder::new();
let nested = NestedQuery::new("locations", MatchQuery::new("locations.country", "JP"));
query.set_query(nested);
}