title: ElasticSearch 5 Sort by Keyword Field Case Insensitive
body: <p>We are using ElasticSearch 5.
  I have a field <code>city</code> using a custom analyzer and the following mapping.</p>
  
  <p><strong>Analyzer</strong></p>
  
  <pre><code>       "analysis": {
            "analyzer": {
              "lowercase_analyzer": {
                "filter": [
                  "standard",
                  "lowercase",
                  "trim"
                ],
                "type": "custom",
                "tokenizer": "keyword"
              }
  }
  </code></pre>
  
  <p>Mapping</p>
  
  <pre><code>  "city": {
      "type": "text",
      "analyzer": "lowercase_analyzer"
    }
  </code></pre>
  
  <p>I am doing this so that I can do a case insensitive sort on the city field. Here is an example query that I am trying to run</p>
  
  <pre><code>{ 
    "query": {
      "term": {
        "email": {
          "value": "some_email@test.com"
        }
      }
    },
  "sort": [
      {
        "city": {
          "order": "desc"
        }
      }
    ]
  }
  </code></pre>
  
  <p>Here is the error I am getting: </p>
  
  <blockquote>
    <p>"Fielddata is disabled on text fields by default. Set fielddata=true
    on [city] in order to load fielddata in memory by uninverting the
    inverted index. Note that this can however use significant memory."</p>
  </blockquote>
  
  <p>I don't want to turn on <code>FieldData</code> and incur a performance hit in ElasticSearch. I would like to have a <code>Keyword</code> field that is not case sensitive, so that I can perform more meaningful aggregations and sorts on it. Is there no way to do this?  </p>