title: elasticsearch mapping tokenizer keyword to avoid splitting tokens and enable use of wildcard
body: <p>I try to make an autocomplete function with angularjs and elasticsearch on a given field, for example <code>countryname</code>. it can contain simple names like "France", "Spain" or "composed names" like "Sierra Leone". </p>
  
  <p>In the mapping this field is <code>not_analyzed</code> to prevent elastic to tokenize "composed names"</p>
  
  <pre><code>"COUNTRYNAME" : {"type" : "string", "store" : "yes","index": "not_analyzed" }
  </code></pre>
  
  <p>I need to query elasticsearch:</p>
  
  <ul>
  <li>to filter the document with something like "countryname:value" where value can contain wildcard</li>
  <li>and make an aggregation on the countryname returned by the filter, ( i do aggregation to get only distinct data, the count is useless for me her, maybe there is a better solution)</li>
  </ul>
  
  <hr>
  
  <p>I can't use wildcard with the "not_analyzed" field :</p>
  
  <p>this is my query but wildcard in "value" variable doesn't work and it's case sensitive : </p>
  
  <p>The wildcard alone her work : </p>
  
  <pre><code>curl -XGET 'local_host:9200/botanic/specimens/_search?size=0' -d '{
    "fields": [
      "COUNTRYNAME"
    ],
    "query": {
      "query_string": {
        "query": "COUNTRYNAME:*"
      }
    },
    "aggs": {
      "general": {
        "terms": {
          "field": "COUNTRYNAME",
          "size": 0
        }
      }
    }
  }'
  </code></pre>
  
  <p>but this doesn't work (franc*) :</p>
  
  <pre><code>curl -XGET 'local_host:9200/botanic/specimens/_search?size=0' -d '{
    "fields": [
      "COUNTRYNAME"
    ],
    "query": {
      "query_string": {
        "query": "COUNTRYNAME:Franc*"
      }
    },
    "aggs": {
      "general": {
        "terms": {
          "field": "COUNTRYNAME",
          "size": 0
        }
      }
    }
  }'
  </code></pre>
  
  <p>I tried also with <code>bool must query</code> but don't work with this not_analyzed field and wildcard : </p>
  
  <pre><code>curl -XGET 'local_host:9200/botanic/specimens/_search?size=0' -d '{
    "fields": [
      "COUNTRYNAME"
    ],
    "query": {
      "bool": {
        "must": [
          {
            "match": {
              "COUNTRYNAME": "Franc*"
            }
          }
        ]
      }
    },
    "aggs": {
      "general": {
        "terms": {
          "field": "COUNTRYNAME",
          "size": 0
        }
      }
    }
  }'
  </code></pre>
  
  <p>What I'm missing or doing wrong? should I left the field <code>analyzed</code> in the mapping and use another analyser who don't split composed name into token??</p>