title: Elasticsearch terms aggregate duplicates
body: <p>I have a field using a ngram analyzer and trying to use a terms aggregate on the field to return unique documents by the field.  The returned keys in the aggregates don't match the documents fields being returned and I'm getting duplicate fields.</p>
  
  <pre><code>"analysis" : {
     "filter" : {
       "autocomplete_filter" : {
          "type" : "edge_ngram",
           "min_gram" : "1",
           "max_gram" : "20"
        }
      },
      "analyzer" : {
        "autocomplete" : {
          "type" : "custom",
          "filter" : [ "lowercase", "autocomplete_filter" ],
          "tokenizer" : "standard"
        }
      }
    }
  }
  
  "name" : {
    "type" : "string",
    "analyzer" : "autocomplete",
    "fields" : {
      "raw" : {
        "type" : "string",
        "index" : "not_analyzed"
      }
    }
  }
  
  {
    "query": {
      "query_string": {
        "query":"bra",
        "fields":["name"],
        "use_dis_max":true
       }
    },
    "aggs": {
      "group_by_name": {
        "terms": { "field":"name.raw" }
      }
    }
  }
  </code></pre>
  
  <p>I'm getting back the following names and keys.</p>
  
  <pre><code>Braingeyser, Brainstorm, Braingeyser, Brainstorm, Brainstorm, Brainstorm, Bramblecrush, Brainwash, Brainwash, Braingeyser
  
  {"key":"Bog Wraith","doc_count":18}
  {"key":"Birds of Paradise","doc_count":15}
  {"key":"Circle of Protection: Black","doc_count":15}
  {"key":"Lightning Bolt","doc_count":15}
  {"key":"Grizzly Bears","doc_count":14}
  {"key":"Black Knight","doc_count":13}
  {"key":"Bad Moon","doc_count":12}
  {"key":"Boomerang","doc_count":12}
  {"key":"Wall of Bone","doc_count":12}
  {"key":"Balance","doc_count":11}
  </code></pre>
  
  <p>How can I get elasticsearch to only return unique fields from the aggregate?</p>