Using Serial Differencing Aggregation in .NET


(Bradley) #1

I'm tring to use Serial Differencing Aggregation in my C# application.

The function was working properly. However, I found there is no instruction to handle the results of Serial Differencing, but only for Sum Aggregation.

Is there anyone who had experience on calling the Serial Differencing results?

Thanks


(Bradley) #2

Sovled by using:
Dictionary.FirstOrDefault()

For example:
var difference = item.Aggregations.FirstOrDefault(x => x.Key == "serial_diff").Value

And get the value by:
((Nest.ValueAggregate)difference).Value


(Russ Cam) #3

Hey @ximenling20, the AggregationsHelper is missing a method for SerialDifferencing(); I'll add one now.

In the meantime, you can get the value as you have done :+1: You could also get it with

if (item.Aggregations.TryGetValue("serial_diff", out IAggregate aggregate))
{
    var serialDifferencingAggregate = (ValueAggregate) aggregate;
}

(Bradley) #4

Hey @forloop, thanks for your quick response and the nice alternative.


(system) #5

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.