Open nickkaltner opened 1 year ago
Thanks - can you share the query you're using?
Hi @tomtaylor this is the documentation for the stats aggregation: https://www.elastic.co/guide/en/elasticsearch/reference/8.11/search-aggregations-metrics-stats-aggregation.html I was surprised that this doesn't follow the standard aggregation. It seems to be a special aggregation.
Maybe an additional struct StatsAggregation? And then one can match on the values of the map to determine whether to return a Snap.Aggregation or a Snap.StatsAggregation?
Something along the lines of:
def build_aggregations(aggregations) when is_map(aggregations) do
Map.new(aggregations, fn
{key, %{"count" => _, "min" => _, "max" => _, "avg" => _, "sum" => _} = value} -> {key, Snap.StatsAggregation.new(value)}
{key, value} -> {key, Snap.Aggregation.new(value)}
end)
end
yeah something as simple as that would be awesome, but at a high level elasticsearch/opensearch support 2 types of aggregations, one is called a bucket aggregation which seems to be supported and the other type is a metrics aggregation which isn't.
even if we had a generic aggregation where it just returned the ES data as json it would at least mean that there was some way to get it with Snap
I can't seem to get stats aggregations to work. I get back something like
I think the problem is that elasticsearch doesn't return buckets etc. for stats aggregations - it returns something like