# Terms aggregation on field with lowercase normalizer

**URL:** <https://discuss.elastic.co/t/terms-aggregation-on-field-with-lowercase-normalizer/301640>\
**Category:** Elasticsearch\
**Created:** [April 5, 2022, 1:21pm UTC](https://discuss.elastic.co/t/terms-aggregation-on-field-with-lowercase-normalizer/301640 "2022-04-05T13:21:28Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![avnere](https://avatars.discourse-cdn.com/v4/letter/a/ba8739/32.png) [@avnere](https://discuss.elastic.co/u/avnere)\
**Post date:** [April 5, 2022, 1:21pm UTC](https://discuss.elastic.co/t/terms-aggregation-on-field-with-lowercase-normalizer/301640/1 "2022-04-05T13:21:28Z")

</div>

Hi,

I mapped the following field:

```auto
"name": {
"type": "keyword",
"normalizer": "lowercase",
"fields": {
"text": {
"type": "text"
}

```

When I run Terms aggregation on this field, I get lowercase results.

How can I get the source results?

---

<div class="post-metadata">

**Author:** ![RabBit\_BR](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rabbit_br/32/82261_2.png) [@RabBit\_BR](https://discuss.elastic.co/u/RabBit_BR)\
**Post date:** [April 5, 2022, 1:53pm UTC](https://discuss.elastic.co/t/terms-aggregation-on-field-with-lowercase-normalizer/301640/2 "2022-04-05T13:53:09Z")

</div>

You want results not normalizer?

maybe aggs by other field like:

```auto
{
  "name": {
    "type": "keyword",
    "normalizer": "lowercase",
    "fields": {
      "text": {
        "type": "text"
      },
      "raw": {
        "type": "keyword"
      }
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![avnere](https://avatars.discourse-cdn.com/v4/letter/a/ba8739/32.png) [@avnere](https://discuss.elastic.co/u/avnere)\
**Post date:** [April 5, 2022, 2:12pm UTC](https://discuss.elastic.co/t/terms-aggregation-on-field-with-lowercase-normalizer/301640/3 "2022-04-05T14:12:48Z")

</div>

Correct I want to get the source results not the normalizer (lowercase) results

---

<div class="post-metadata">

**Author:** ![RabBit\_BR](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rabbit_br/32/82261_2.png) [@RabBit\_BR](https://discuss.elastic.co/u/RabBit_BR)\
**Post date:** [April 5, 2022, 4:22pm UTC](https://discuss.elastic.co/t/terms-aggregation-on-field-with-lowercase-normalizer/301640/4 "2022-04-05T16:22:47Z")

</div>

try aggs by "name.raw"

```auto
{
  "size": 0, 
  "aggs": {
    "names": {
      "terms": { "field": "name.raw" }
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![avnere](https://avatars.discourse-cdn.com/v4/letter/a/ba8739/32.png) [@avnere](https://discuss.elastic.co/u/avnere)\
**Post date:** [April 7, 2022, 6:40am UTC](https://discuss.elastic.co/t/terms-aggregation-on-field-with-lowercase-normalizer/301640/5 "2022-04-07T06:40:30Z")

</div>

This means the you need to add additional keyword type to the field, I want to avoid it.  
The field source is already keyword and I want the aggs will run on it and not on the normalizer.

---

<div class="post-metadata">

**Author:** ![RabBit\_BR](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rabbit_br/32/82261_2.png) [@RabBit\_BR](https://discuss.elastic.co/u/RabBit_BR)\
**Post date:** [April 7, 2022, 12:54pm UTC](https://discuss.elastic.co/t/terms-aggregation-on-field-with-lowercase-normalizer/301640/6 "2022-04-07T12:54:15Z")

</div>

Anyway, you should change your mapping.  
If you want to apply it to the keyword, apply the normalizer to the "text" field.

---

<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:** [May 5, 2022, 12:54pm UTC](https://discuss.elastic.co/t/terms-aggregation-on-field-with-lowercase-normalizer/301640/7 "2022-05-05T12:54:23Z")

</div>

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