Open
Description
Is your feature request related to a problem? Please describe.
Not a problem, actually, but I would be way more cool, sometimes, to use builder pattern to build queries. Like it was implemented in high-level ES client for dotnet.
Example: https://www.elastic.co/guide/en/elasticsearch/client/net-api/7.17/writing-queries.html
Describe the solution you'd like
Usage of builder pattern, like in dotnet client:
var searchResponse = _client.Search<Project>(s => s
.Query(q => q
.DateRange(r => r
.Field(f => f.StartedOn)
.GreaterThanOrEquals(new DateTime(2017, 01, 01))
.LessThan(new DateTime(2018, 01, 01))
)
)
);
Rust
let req = builder::new().match("querytext").aggs(agg:Terms("field")).source(false)
Describe alternatives you've considered
only using json! macro with the body.
Additional context
some more complex query example.
var searchResponse = _client.Search<Project>(s => s
.Query(q => q
.Bool(b => b
.Must(mu => mu
.Match(m => m
.Field(f => f.LeadDeveloper.FirstName)
.Query("Russ")
), mu => mu
.Match(m => m
.Field(f => f.LeadDeveloper.LastName)
.Query("Cam")
)
)
.Filter(fi => fi
.DateRange(r => r
.Field(f => f.StartedOn)
.GreaterThanOrEquals(new DateTime(2017, 01, 01))
.LessThan(new DateTime(2018, 01, 01))
)
)
)
)
);