-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Description
First let me say that I am very pleased that you offer both fluent and object initialization syntaxes. There are times where I will use one or the other.
That being said, I feel that there can be some excessive verbosity when writing a complex query using the object initializer syntax. The following example illustrates all three of the points I have noticed so far:
var aggregations = new Dictionary<string, IAggregationContainer>
{
{
"my_aggregation", new AggregationContainer
{
Filter = new FilterAggregator
{
Filter = (FilterContainer)new QueryFilter
{
Query = (QueryContainer)new QueryStringQuery
{
Query = "Just an example"
}
}
}
}
}
};PlainQuerywill implicitly cast toQueryContainerbut notIQueryContainerPlainFilterwill implicitly cast toFilterContainerbut notIFilterContainer- Aggregators must be wrapped in an
AggregationContainereven if you are only specifying that aggregator without any subaggregations or other options; there is no cast from a single aggregator to a container like there is for queries and filters, let alone a cast toIAggregationContainer
If such casting was offered by the library, the above snippet could look like this:
var aggregations = new Dictionary<string, IAggregationContainer>
{
{
"my_aggregation", new FilterAggregator
{
Filter = new QueryFilter
{
Query = new QueryStringQuery
{
Query = "Just an example"
}
}
}
}
};Metadata
Metadata
Assignees
Labels
No labels