How to get total term frequency through aggregation in elastic


In a search result, I want to get the total number of times a term has showed in the list of documents returned. By only using term aggregations, I can only get the doc count but what I want is the total number of terms occurred across the entire set.

For example:

Name: David
Tech: A1, A1, B1, B1, C1

Name: Josh
Tech: C1, D1, E1

Name: David
Tech: A1, D1, F1

when I search for 'David' in the field 'Name' I will get normally get my 'Tech' aggregation as:

A1: 2
B1: 1
C1: 1
D1: 1
F1: 1

whereas I want my results to show:

A1: 3
B1: 2
C1: 1
D1: 1
F1: 1

Is there anyway I can do this with aggregations?

Thank you!

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