title: How to sort on field type ''text" in Elastic search
body: <p>I am working on elastic search multiple field sort query, I have data in the following format:</p>
  <pre><code>{
    &quot;person_name&quot; : &quot;Abraham Benjamin deVilliers&quot;,
    &quot;created_on&quot;: &quot;Tue, 02 Apr 2018 16: 17: 54 GMT&quot;,
    &quot;name&quot;: &quot;Abraham&quot;,
    &quot;office&quot;:{
       &quot;name&quot;:&quot;my_office&quot;
    }
  },
  {
    &quot;person_name&quot; : &quot;John Bradshaw&quot;,
    &quot;created_on&quot;: &quot;Thu Apr 05 2018 14:42:30 GMT&quot;,
    &quot;name&quot;: &quot;jhon&quot;,
    &quot;office&quot;: {
       &quot;name&quot;:&quot;Abraham deVilliers&quot;
    }
  },
  {
    &quot;person_name&quot; : &quot;John Bradshaw&quot;,
    &quot;created_on&quot;: &quot;Tue, 03 Apr 2018 11: 39: 17 GMT&quot;,
    &quot;name&quot;: &quot;Abraham deVilliers&quot;,
    &quot;office&quot;: {
       &quot;name&quot;:&quot;blabla&quot;
    }
  }
  </code></pre>
  <p>Where the field <code>person_name</code> is of type <code>text</code> and <code>created_on</code> is of type <code>string</code>. I have to sort the above response based on the fields <code>person_name</code> and <code>created_on</code>.</p>
  <p>The query we tried is as follows:</p>
  <pre><code>GET /my_index/_search
  
  {
      sort: [{ 
               &quot;person_name&quot;: { &quot;order&quot;: &quot;asc&quot; },
               &quot;created_on&quot;: { &quot;order&quot;: &quot;desc&quot; }
      }]
  }
  </code></pre>
  <p>While sorting response with the above query I am getting the following error:</p>
  <blockquote>
  <p>message: '[illegal_argument_exception] Fielddata is disabled on text
  fields by default. Set fielddata=true on [person_name] in order to
  load fielddata in memory by uninverting the inverted index. Note that
  this can however use significant memory. Alternatively use a keyword
  field instead.'</p>
  </blockquote>
  <p>On searching, we found we need to modify the mapping of the field <code>person_name</code> from type <code>text</code> to of type <code>keyword</code>. But we can't modify existing mapping as it already contains millions of records.</p>
  <p>Is there any other way to perform a sort query on the <code>text</code> field without altering the existing mapping of elastic search?.</p>
  <p>Any help will be appreciated.</p>