title: Get count for unique terms
body: <p>In elasticsearch, I want to get unique terms and counts for that terms.</p>
  
  <pre>
  index:
  doc1: filetype(multivalued): pdf, zip, zip, txt
  
  expected result:
  pdf: 1
  zip: 2
  txt: 1
  </pre>
  
  <p>I made this query, but I got an error.</p>
  
  <pre><code>"aggs": {
      "uniqueTerms": {
          "terms": {
              "field": "filetype"
          }
      },
      "aggs": {
          "count": {
              "cardinality": {
                  "field": "filetype"
              }
          }
      }
  }
  </code></pre>
  
  <p>How can I make a query to get the result?</p>
  
  <p>index mapping updated:</p>
  
  <pre><code>"file" : {
      "properties" : {
          "filetype" : {
              "type" : "string",
              "norms" : {
                  "enabled" : false
              },
              "fields" : {
                    "raw" : {
                        "type" : "string",
                        "index" : "not_analyzed",
                        "ignore_above" : 256
                    }
                }
            }
        }
  }
  </code></pre>