title: Elastic Search Group by field
body: <p>I have the following data in my index.</p>
  
  <pre><code>{
  "id":1,
  "car_name" : "ABC-101"
  },
  {
  "id":2,
  "car_name" : "DEF-102"
  },
  {
  "id":3,
  "car_name" : "ABC-103"
  }
  </code></pre>
  
  <p>Mapping of my index is</p>
  
  <pre><code>{
    "car": {
      "mappings": {
        "_doc": {
          "properties": {
            "car_name": {
              "type": "text",
              "fielddata": true
            }
          }
        }
      }
    } 
  }
  </code></pre>
  
  <p>Whey i run the following query</p>
  
  <pre><code> localhost:9200/car/_doc/_search?pretty
  </code></pre>
  
  <p>With following request body</p>
  
  <pre><code>{
  "size" : 0,
  "aggs" : {
      "genres" : {
          "terms" : { 
              "field" : "car_name"
          }
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>I get the following response</p>
  
  <pre><code>"buckets": [
      {
        "key": "ABC",
        "doc_count": 2
      },
      {
        "key": "DEF",
        "doc_count": 1
      },
      {
        "key": "101",
        "doc_count": 1
      },
      {
        "key": "102",
        "doc_count": 1
      },
      {
        "key": "103",
        "doc_count": 1
      }
  ]
  </code></pre>
  
  <p>Why it is not bring the actual keys which are ABC-101 and DEF-102 why ABC and 101 are treated as separated keys.</p>