Slice size: sum specific fields for documents which are unique in another fields

Hi all!

Please help me understand something about pie chart.

Can I get sum of values in specific field of documents for documents which are unique in another field (as slice size). For example, we have documents with fields "Number of apples" and "id" of person, who has these apples in his bag. We get new documents about these people with (often) unchanged number of apples several times per hour. When we choose sum of "Number of apples" as slice size, we want to count this field only once for specific person, so we want to get sum of "Number of apples" for documents which are unique in "id" field. How can we do it?

Sorry for my bad English! Hope, my question is clear.

Thanks,
Darya

Is this not just the unique count aggregation?

@jclose, Unique count aggregation with what field (for my example)?

This would be a unique count for the 'apples' field. Basically, each slice of the pie will correlate to X number of apples.

So if you have the following:
ID:1 Apples:2
ID:2 Apples:3
ID:3 Apples:2
ID:4 Apples:4
ID:5 Apples:5
ID:6 Apples:2

You would have a pie chart with 4 slices (2, 3, 4, and 5). The slice for 2-apples would be 3x as big as the other slices, as it would correlate to IDs 1,3, and 6.

Thank you, @jclose.

And can we get this result (in your answer) if we choose Count as slice size and apples as field for split slices?

I think my question is about other thing. In my example I have something like:
DocID: 1, PersonID: 1, Apples: 2, BagColor: blue, another fields...
DocID: 2, PersonID: 1, Apples: 2, BagColor: blue, another fields...
DocID: 3, PersonID: 2, Apples: 3, BagColor: blue, another fields...
DocID: 4, PersonID: 2, Apples: 3, BagColor: blue, another fields...
DocID: 5, PersonID: 3, Apples: 2, BagColor: yellow, another fields...
DocID: 6, PersonID: 3, Apples: 2, BagColor: yellow, another fields...
DocID: 7, PersonID: 4, Apples: 4, BagColor: green, another fields...
DocID: 8, PersonID: 4, Apples: 4, BagColor: green, another fields...

I build pie chart with following metrics and buckets:
Slice size = sum of apples
Split slices by value of BagColor

And I want to get something like
Slice 1 about Blue Bag with size = 5 apples
Slice 2 about Yellow Bag with size = 2
Slice 3 about Green Bag with size = 4

So I want my sum of apples to be counted as
Apples in doc with DocID:1 + apples in doc with DocID: 3 + apples in doc with DocID: 5 + apples in doc with DocID: 7 (unique in PersonID).

If seems that I can't get it if I choose Unique count of apples as slice size

So, on that example, you want:

Each slice to be the sum of apples for each unique PersonID?

Will the PersonID always be the same for each DocID where that person exists? So will there ever be a case where you have PersonID: 1, Apples: 2, and then another data point with PersonID: 1, Apples: 3?

@jclose, sorry that the answer took so long!

Yes, each person has unique (the same) personID in all documents with info about him.

Yes, apples number is something that changes over time, but because we get info about it for each person so often (several times per hour), in some documents for one person there is the same value.

I want each slice to be the sum of apples for all unique PersonID with bag of specific colour.

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