# How to get total term frequency through aggregation in elastic

**URL:** https://discuss.elastic.co/t/how-to-get-total-term-frequency-through-aggregation-in-elastic/248483
**Category:** Elasticsearch
**Created:** [September 14, 2020, 7:57am UTC](https://discuss.elastic.co/t/how-to-get-total-term-frequency-through-aggregation-in-elastic/248483 "2020-09-14T07:57:44Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Ubeta](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ubeta/32/70991_2.png) [@Ubeta](https://discuss.elastic.co/u/Ubeta)
#### Post date: [September 14, 2020, 7:57am UTC](https://discuss.elastic.co/t/how-to-get-total-term-frequency-through-aggregation-in-elastic/248483/1 "2020-09-14T07:57:45Z")

</div>

Hi!

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:

```auto
doc1:
Name: David
Tech: A1, A1, B1, B1, C1

doc2: 
Name: Josh
Tech: C1, D1, E1

doc3:
Name: David
Tech: A1, D1, F1

```

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

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

```

whereas I want my results to show:

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

```

Is there anyway I can do this with aggregations?

Thank you!

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [October 12, 2020, 7:57am UTC](https://discuss.elastic.co/t/how-to-get-total-term-frequency-through-aggregation-in-elastic/248483/2 "2020-10-12T07:57:58Z")

</div>

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