# Term counts aggregation for complete index field

**URL:** https://forum.opensearch.org/t/term-counts-aggregation-for-complete-index-field/12018
**Category:** OpenSearch
**Tags:** discuss
**Created:** [January 5, 2023, 12:57pm UTC](https://forum.opensearch.org/t/term-counts-aggregation-for-complete-index-field/12018 "2023-01-05T12:57:37Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![peter.coppens](https://avatars.discourse-cdn.com/v4/letter/p/bcef8e/32.png) [@peter.coppens](https://forum.opensearch.org/u/peter.coppens)
#### Post date: [January 5, 2023, 12:57pm UTC](https://forum.opensearch.org/t/term-counts-aggregation-for-complete-index-field/12018/1 "2023-01-05T12:57:37Z")

</div>

Hello

I am learning OpenSearch (using version 2.4.1)

I am trying to create an aggregate that will count (e.g. top 50) words (or terms/keywords) that a text (or keyword or …) field contains in a given data stream

I ran across something like

```auto
POST mydatastream/_search
{
  "size": 0,
  "aggs": {
    "term_frequencies": {
      "terms": {
        "field": "message.keyword",
        "size": 30
      }
    }
  }
}

```

(message is mixed text/keyword) field

This works but it takes the complete document as ‘thing’ to count and not the individual words/terms/keywords

I also ran into

```auto
GET /.ds-mydatastream-000001/_mtermvectors
{
  "ids": [..,...],
  "parameters": {
      "fields": ["message"],
      "term_statistics": true,
      "offsets":false,
      "payloads":false,
      "positions":false
  }
}

```

That’s more what I want but it requires the ids to be specified (which also is not an option in my case)

Can someone point me in the right direction?

Tx!

Peter
