# Elastic Search Aggregation Based On Case Insensitive

**URL:** <https://discuss.elastic.co/t/elastic-search-aggregation-based-on-case-insensitive/358435>\
**Category:** Elasticsearch\
**Created:** [April 29, 2024, 2:13pm UTC](https://discuss.elastic.co/t/elastic-search-aggregation-based-on-case-insensitive/358435 "2024-04-29T14:13:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ranjithkumar.rottela](https://avatars.discourse-cdn.com/v4/letter/r/f05b48/32.png) [@ranjithkumar.rottela](https://discuss.elastic.co/u/ranjithkumar.rottela)\
**Post date:** [April 29, 2024, 2:13pm UTC](https://discuss.elastic.co/t/elastic-search-aggregation-based-on-case-insensitive/358435/1 "2024-04-29T14:13:07Z")

</div>

Hi Team,

I have requirement I need to fetch data in Elasticsearch case insensitivity, but need on both key and value field.

Sample code below

```auto
POST test-index999/_doc
{
  "key": "testKey:testValue",
  "count": 200,
  "id": "test123"
}

```

Another document

```auto
POST test-index999/_doc
{
  "key": "testKey:testValue",
  "count": 100,
  "id": "test123"
}

```

Expected Output

```auto
GET test-index999/_search
{
  "query": {
    "match": {
      "id": "test123"
    }
  },
 "aggs": {
     "byCat": {
        "terms": {
            "field": "key"
         }
      }
  }
}

```

Can I get below output

```auto
"aggregations": {
     "byCat": {
        "key": "testkey:testvalue",
        "count": 300
     }
}

```

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [April 29, 2024, 2:28pm UTC](https://discuss.elastic.co/t/elastic-search-aggregation-based-on-case-insensitive/358435/2 "2024-04-29T14:28:30Z")

</div>

Welcome!

Your post is incomplete. Could you do it again?
