# Is it possible to count each term of a text instead of the complete text to display in Kibana?

**URL:** <https://discuss.elastic.co/t/is-it-possible-to-count-each-term-of-a-text-instead-of-the-complete-text-to-display-in-kibana/73715>\
**Category:** Elasticsearch\
**Created:** [February 2, 2017, 4:11pm UTC](https://discuss.elastic.co/t/is-it-possible-to-count-each-term-of-a-text-instead-of-the-complete-text-to-display-in-kibana/73715 "2017-02-02T16:11:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![DrBatoon](https://avatars.discourse-cdn.com/v4/letter/d/cc9497/32.png) [@DrBatoon](https://discuss.elastic.co/u/DrBatoon)\
**Post date:** [February 2, 2017, 4:11pm UTC](https://discuss.elastic.co/t/is-it-possible-to-count-each-term-of-a-text-instead-of-the-complete-text-to-display-in-kibana/73715/1 "2017-02-02T16:11:32Z")

</div>

Hi! Im completely new to ES. I have the time and text of tweets stored in a CSV file. I'am using logstash to get them over ES. When I'm using Kibana's Tag Cloud to display the most common words in the tweets, every tweet is considered one term. Is it possible to make Kibana count every term in every tweet instead of just every tweet?

EXAMPLE:  
[2017-02-01, foo foo bar]  
[2017-02-01, foo bar]  
[2017-02-01, foo bar]

RESULT:  
2 counts: foo bar  
1 count: foo foo bar

WHAT I ACTUALLY WANT:  
4 counts: foo  
3 counts: bar

and then display this in Kibana

---

<div class="post-metadata">

**Author:** ![Deuneuv](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/deuneuv/32/15151_2.png) [@Deuneuv](https://discuss.elastic.co/u/Deuneuv)\
**Post date:** [February 2, 2017, 5:13pm UTC](https://discuss.elastic.co/t/is-it-possible-to-count-each-term-of-a-text-instead-of-the-complete-text-to-display-in-kibana/73715/2 "2017-02-02T17:13:08Z")

</div>

I think you need to modifiy your index file configuration and choose the specify analyzer for your need

[Elasticsearch Reference [5.2] » Analysis » Analyzers](https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-analyzers.html)

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [February 2, 2017, 5:56pm UTC](https://discuss.elastic.co/t/is-it-possible-to-count-each-term-of-a-text-instead-of-the-complete-text-to-display-in-kibana/73715/3 "2017-02-02T17:56:07Z")

</div>

The field should be a normal text field, which is analyzed, and not a  
keyword field, which is not. You can define further analysis if you want,  
but the standard analyzer should be good for most scenarios.

After that, you simply run a terms aggregation over the field, but the  
field needs to have fielddata enabled:  
[https://www.elastic.co/guide/en/elasticsearch/reference/current/fielddata.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/fielddata.html)

I do not use kibana or logstash, so I do not know how those systems are  
configured.

---

<div class="post-metadata">

**Author:** ![DrBatoon](https://avatars.discourse-cdn.com/v4/letter/d/cc9497/32.png) [@DrBatoon](https://discuss.elastic.co/u/DrBatoon)\
**Post date:** [February 3, 2017, 9:21am UTC](https://discuss.elastic.co/t/is-it-possible-to-count-each-term-of-a-text-instead-of-the-complete-text-to-display-in-kibana/73715/4 "2017-02-03T09:21:08Z")

</div>

I am trying with

```
PUT twitter/_mapping/twitter_text

{
   "twitter_text": {
      "properties": {
        "publisher": {
          "type": "text",
          "fielddata": false
        }
      }
   }
}

```

And the mapping says

```
GET /twitter/_mapping
"twitter": {
      "mappings": {
         "twitter_text": {
            "_all": {
               "enabled": true,
               "norms": false
            },
            "dynamic_templates": [
               {
                  "message_field": {
                     "path_match": "message",
                     "match_mapping_type": "string",
                     "mapping": {
                        "norms": false,
                        "type": "text"
                     }
                  }
               },
               {
                  "string_fields": {
                     "match": "*",
                     "match_mapping_type": "string",
                     "mapping": {
                        "fields": {
                           "keyword": {
                              "type": "keyword"
                           }
                        },
                        "norms": false,
                        "type": "text"
                     }
                  }
               }
            ],

```

And twitter\_text is still not aggregatable. What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![DrBatoon](https://avatars.discourse-cdn.com/v4/letter/d/cc9497/32.png) [@DrBatoon](https://discuss.elastic.co/u/DrBatoon)\
**Post date:** [February 3, 2017, 11:04am UTC](https://discuss.elastic.co/t/is-it-possible-to-count-each-term-of-a-text-instead-of-the-complete-text-to-display-in-kibana/73715/5 "2017-02-03T11:04:04Z")

</div>

Figured I had to build the index before populating it. Build it like

```
PUT twitter666
{
  "mappings": {
    "tweet": { 
      "_all": { "enabled": false }, 
      "properties": {  
        "twitter_text": { "type": "text", "fielddata": true }, 
        "user": { "type": "text" },
        "country": { "type": "text" },
        "longitude": {"type":"float"},
        "longitude": {"type":"float"}
      }
    }
  }
}
```

---

<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:** [March 3, 2017, 11:04am UTC](https://discuss.elastic.co/t/is-it-possible-to-count-each-term-of-a-text-instead-of-the-complete-text-to-display-in-kibana/73715/6 "2017-03-03T11:04:04Z")

</div>

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