Aggregate 7 fields and get the sum of another field

Hi All,

I have a scenario , where I would need to aggregate 7 fields and get the sum of other field with each unique set . Any suggestions which would solve my issue.

Hi,

it depends, can you be a bit more specific?

aggregate 7 fields

7 different fields? What aggregation? Sum? If it's different fields, I think you need a scripted_metric as aggs normally work on 1 field, not a list of fields.

with each unique set

Do you want this for all your data or just for a specific subset? If you want it only for a specific id or a some id's you can do this as part of a search request.

If you want to aggregate the whole data set you can use a composite aggregation, this enables you to page trough the results. This is good if you want to directly process the output.

If you want to store the results in an index, have a look at transform, which is basically a wrapper around composite aggregation that writes the output to a new index.

Hi Hendrik,

Thanks for you reply.

I would need to get unique values from 7 different fields and get per day cost [aggregation] of this result set .

This would need to be executed on whole data in the index not on a subset .

Thanks In Advance.

Does unique values mean the number of different values, aka cardinality? -> cardinality aggregation

Or do you need the exact values? -> terms aggregation

As said, have a look at composite aggregation. However, as you mention "per day", I assume you want to run the repeatedly. If that's the case, I think transform might be the right tool. It ships with a UI in kibana which is a great helper to setup a transform.

1 Like

Thanks for your help Hendrick

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