Comments (5)
I see. OK. Thanks.
from elasticsearch-net.
Hi @gpetrou! With the new generator design, aggregation variants do not derive from a common base-class anymore (the same thing as for the Query
variants).
I'm fine with adding back this functionality to Aggregation
, but this will still require to wrap the individual aggregation variants into the container first, before using the operator.
var aggregations = Aggregation.Min(...) && Aggregation.Max(...);
would work fine in this case, but the previously available syntax won't:
var aggregations = new MinAggregation{...} && new MaxAggregation{...};
from elasticsearch-net.
Well, nevermind. I remember why I did not re-implement this 😋
In the versions prior to 8.12, the name of the aggregation was pulled into the actual variant. For example, MinAggregation
has a constructor that accepts the aggregation name.
In the versions starting with 8.13, this got changed to be consistent with the resulting JSON structure (the aggregation name is a key in a dictionary and the aggregation variant is the corresponding value).
The old design caused many issues, because it required a lot of hacks during serialization (have a look at AggregationDictionary
).
In consequence, this means that we can not compose a dictionary of aggregations from the individual aggregation variants using the &&
operator, because there is no way to "store" the aggregation name.
But in my opinion, the reason for introducing &&
in NEST, is no longer relevant as well. In NEST, aggregation dictionaries had to be initialized like:
Aggregations = new AggregationDictionary
{
{"average_per_child", new AverageAggregation("average_per_child", ...)},
{"max_per_child", new MaxAggregation("max_per_child", ...)},
{"min_per_child", new MinAggregation("min_per_child", ...)},
}
and the &&
syntax simplified that a little bit:
Aggregations =
new AverageAggregation("average_per_child", ...)
&& new MaxAggregation("max_per_child", ...)
&& new MinAggregation("min_per_child", ...)
In the latest version of the 8.x client, initialization is more straightforward anyways:
Aggregations = new Dictionary<string, Aggregation>
{
{"average_per_child", Aggregation.Average(...)},
{"max_per_child", new MaxAggregation(...)},
{"min_per_child", new MinAggregation(...)},
}
from elasticsearch-net.
I hope you understand, that I can not bring this functionality back for technical reasons. I will make sure to document that in the release notes of 8.13.0.
from elasticsearch-net.
@flobernd, can you show me how to initialize Aggregation with aggregations in the latest 8.13.* client?
How "translate" this query in C#:
{
"from": 0,
"size": 100,
"collapse": {
"field": "uniqueId"
},
"query": {
"match": {
"Content": "test word"
}
},
"aggregations": {
"my-terms aggs": {
"terms": {
"field": "seqId",
"size": 100
},
"aggregations": {
"my-cardinality-agg": {
"cardinality": {
"field": "uniqueId"
}
}
}
}
}
}
- i must set and use "my-terms aggs" and "my-cardinality-agg" in code
- uniqueId and seqId are different fields
- search is performed on aliases that may contain duplicates
I tried
Aggregation.Terms(new TermsAggregation
{
Field = Infer.Field("seqId"),
Size = 100
}).Aggregations = new Dictionary<string, Aggregation>
{
{
"my-cardinality-agg",
new CardinalityAggregation { Field = "uniqueId" }
}
}
but how to set up name "my-terms aggs" in TermsAggregation in that case?
from elasticsearch-net.
Related Issues (20)
- ExtendedBounds missing from DateHistogramAggregationDescriptor<TDocument> HOT 1
- Unable to perform knn query [knn] unknown field [k HOT 7
- Dictionary exception in BucketsPathConverter HOT 5
- Elasticsearch.Net.UnexpectedElasticsearchClientException: Failed to serialize anonymous type when writting to NLog HOT 3
- Another Elastic.Transport.UnexpectedTransportException with Ingest.GetPipelineAsync HOT 2
- Reintroduce convenience where appropriate HOT 4
- Default index is not used in query with 8.13.8 client HOT 5
- Missing Public Constructor on Type Elastic.Clients.Elasticsearch.Fields HOT 2
- SumAggregation missing ctor HOT 7
- BulkAll does not honor [JsonIgnore] attribute HOT 2
- GeoPoint Serialization Helper HOT 3
- MultiGetAsync does not infer default mapping for index HOT 4
- Support for (alternative for) GeoShapeQuery HOT 2
- After/AfterKey dictionary types in Composite Aggregation/Aggregate HOT 1
- 8.13.10 lacks UpdateMany<TSource, TPartialDocument>
- Latest MINOR package version does not support .Net 6 anymore. HOT 3
- Elastic.Transport.UnexpectedTransportException with Indices.GetAsync HOT 4
- Indices.ExistsAsync throw exception due to ICU field HOT 6
- Queries are no longer derive from SearchQuery HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from elasticsearch-net.