Vycka / ElasticSearch.Client

User-Friendly ElasticSearch c# client for Selecting and Aggregating data queries.
GNU General Public License v2.0
10 stars 1 forks source link

Sub-Aggregations #3

Closed skind closed 8 years ago

skind commented 9 years ago

Hey Vycka, as I always say - great LIB to use!! Now I have another proposal for extending your LIB: Sub-Aggregations. As I mentioned in another Issue I request Elastic for sold cars. I got the total amount for each date -this is not the Problem. I want to get how many sold cars in each Country (e.g. Germany, France, Italy, ... ) in the same request AND maybe when possible which car vendors in each Country( e.g. Germany: 'Audi', BMW', 'Opel'; France: 'Peugeot', Citroen', ..). I know I can do this with several request against Elastic - but for saving load and time I think ths could be a very cool Feature when I get this Information in one request - what do you think about this? Thank you in advance!! skind

Vycka commented 9 years ago

Hey, maybe this is what you are looking for? https://github.com/Vycka/ElasticSearch.Client/blob/master/src/ElasticSearch.Playground/Samples/NestedAggregationsV2.cs

skind commented 9 years ago

..no, it is not that. It is more, lets say a cascading request: (rememeb my example)

01.09.2015 +Country: Germany - TotalSoldCars: 2000 | | (Subaggregation) --> +Type: Audi: TotalSoldCar: 1000 +Type: BMW:TotalSoldCar: 1000

  +Country: France  - TotalSoldCars: 1000 
               |
               | (Subaggregation) --> +Type: Peugeo:  
                                                             -->  TotalSoldCar: 600
                                                    +Type: Citroen 
                                                              --> TotalSoldCar: 400

02.09.2015 +Country: Germany - TotalSoldCars: 1200 | | (Subaggregation) --> +Type: Audi
--> TotalSoldCar: 800 +Type: BMW --> TotalSoldCar: 400

  +Country: France  - TotalSoldCars: 1400 
               |
               | (Subaggregation) --> +Type: Peugeot
                                                                -->  TotalSoldCar: 900
                                                    +Type: Citroen 
                                                                 --> TotalSoldCar: 500

I hope this explains more what I mean: one request and multiple appregations Best regards, skind

Vycka commented 9 years ago

Added missing interfaces on histogram aggregates, they can now be used in SubAggregations:

https://github.com/Vycka/ElasticSearch.Client/blob/6076af158960df0f6113ecc0a1a9f7ea7a2f10c1/src/ElasticSearch.Playground/Samples/Aggregates/SubAggregates.cs

Functionality is there, but I guess a better SubAggregation builder might bi required in the future.

P.s. upgrading of a nuget package is required.

I hope this helps?

skind commented 9 years ago

..checked teh SubAggregations - and - another time worked immediately!! Thanks a lot for that! Do you continue the work for better SubAggregations? I'm looking forward for it. Best regards skind

Vycka commented 9 years ago

For better aggregation builder: at this moment - no Though, if you have any ideas, how it should look or work (for easier kick-start), feel free to share :)