title: ElasticSearch terms aggregation by entire field
body: <p>How can I write an ElasticSearch term aggregation query that takes into account the entire field value, rather than individual tokens? For example, I would like to aggregate by city name, but the following returns <code>new</code>, <code>york</code>, <code>san</code> and <code>francisco</code> as individual buckets, not <code>new york</code> and <code>san francisco</code> as the buckets as expected.</p>
  
  <pre><code>curl -XPOST "http://localhost:9200/cities/_search" -d'
  {
     "size": 0, 
     "aggs" : {
       "cities" : {
           "terms" : { 
              "field" : "city",
              "min_doc_count": 10
           }
       }
     }
  }'
  </code></pre>