title: ElasticSearch not sorting results
body: <p>I'm trying to sort the results based on a <code>numeric</code> field,</p>
  
  <p>Here is my mapping:</p>
  
  <pre><code>{
    "elasticie": {
      "mappings": {
        "properties": {
          "name": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "number": {
            "type": "long"
          }
        }
      }
    }
  }
  </code></pre>
  
  <p>I'm using Python, and this is my testing data:</p>
  
  <pre class="lang-py prettyprint-override"><code>data = [
      {'name': 'sElwUYiLXGHaQCKbdxtnvVzqIehfFWkJcPSTurgNoRD', 'number': 8583},
      {'name': 'XJEtNsIFfcwHTMhqAvRkiygjbUGzZQPdS', 'number': 8127},
      {'name': 'ZIeAGosUKJbjOdylM', 'number': 5862},
      {'name': 'HYvcafoXkC', 'number': 7458},
      {'name': 'tATJCjNuizOlGckXBpyVqSQL', 'number': 530},
      {'name': 'TFYixotjhXzNZPvHnkraRDpAMEImJfqdcVGLC', 'number': 7052},
      {'name': 'JCEGfoKDHRrcIkPQSqiVgNshZOBaMdXjAlxwUzmeWLy', 'number': 6168},
      {'name': 'IpCTwUAQynSizJtcsuDmbX', 'number': 6492},
      {'name': 'fTrcoXSBJNFhAkzWpDMxsEiLmZRvgnC', 'number': 382},
      {'name': 'ulVNmqKTpPXfEIdiykhDjMrUGOYazLBFvgnWwsRtJoQbxSe', 'number': 2061}
  ]
  </code></pre>
  
  <p>Using following code, I'm creating the index and inserting the data:</p>
  
  <pre><code>from elasticsearch import Elasticsearch
  from data import data  # the data I've shown above
  
  INDEX = 'elasticie'
  es = Elasticsearch('http://127.0.0.1:9200')
  
  for _ in data:
      es.index(index=INDEX, body=_)
  </code></pre>
  
  <p>I'm trying to sort data based on number, <code>asc</code> or <code>desc</code>
  Here is what I tried so far:</p>
  
  <pre><code>es.search(index=INDEX, params={'sort': {'number': {'order': 'asc'}})
  es.search(index=INDEX, params={'sort': {'number': 'asc'})
  es.search(index=INDEX, params={'sort': [('number', 'asc')]})
  es.search(index=INDEX, params={'sort': {'number': {'order': 'asc', 'ignore_unmapped': True}})
  es.search(index=INDEX, params={'sort': {'number': {'order': 'asc', 'unmapped_type': 'integer'}})
  es.search(index=INDEX, params={'sort': {'number': {'order': 'asc', 'unmapped_type': 'long'}})
  es.search(index=INDEX, params={'sort': {'number.raw': 'asc'})
  </code></pre>
  
  <p>Not of the above methods worked for me, The result is the same as the inserted data,
  If I assign the above lines to a variable named <code>search_result</code> and print the result using the following code:</p>
  
  <pre><code>for index, result in enumerate(search_result['hits']['hits']):
      print(f'{index}. {result["_source"]["number"]}')
  </code></pre>
  
  <p>I'll get the following result:</p>
  
  <pre><code>0. 8583
  1. 8127
  2. 5862
  3. 7458
  4. 530
  5. 7052
  6. 6168
  7. 6492
  8. 382
  9. 2061
  </code></pre>
  
  <p>Which is obviously not sorted using <code>number</code> field!!</p>
  
  <p>I don't know what I'm doing wrong, I'm using ElasticSearch 7.6 and Python 3.8</p>
  
  <p>How can I make the sorting results work?</p>
  
  <p><strong>Update</strong></p>
  
  <p>Based on debugging logs, Python is sending a <code>GET</code> request to the following URL using the first method:
  <code>http://127.0.0.1:9200/elasticie/_search?sort={%27number%27%3A+{%27order%27%3A+%27asc%27}}</code></p>