Sort does not work properly with from size parameter on elastic 7.2

Hello All,

We are using elastic 7.2 via rest high-level client on kotlin app. When we try to use below query sort return as false.It seems like sorting string instead of number like 1000->101->102 it looks third digit first 0 second 1 and last 2 than order like that.

GET attribute-lookup/_search
{
  "from": 10,
  "size": 5,
  "query": {
"bool": {
  "filter": [
    {
      "match_all": {
        "boost": 1
      }
    }
  ]
}
  },
  "_source": {
"includes": [
  "realId"
],
"excludes": []
  },
  "sort": [
{
  "realId": {
    "order": "asc"
  }
}
  ],
  "track_total_hits": 2147483647
}

and result is

{
  "took" : 2,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 348,
      "relation" : "eq"
    },
    "max_score" : null,
    "hits" : [
      {
        "_index" : "lookup__20190904_0723",
        "_type" : "_doc",
        "_id" : "attribute/108",
        "_score" : null,
        "_source" : {
          "realId" : 108
        },
        "sort" : [
          "108"
        ]
      },
      {
        "_index" : "lookup__20190904_0723",
        "_type" : "_doc",
        "_id" : "attribute/109",
        "_score" : null,
        "_source" : {
          "realId" : 109
        },
        "sort" : [
          "109"
        ]
      },
      {
        "_index" : "lookup__20190904_0723",
        "_type" : "_doc",
        "_id" : "attribute/11",
        "_score" : null,
        "_source" : {
          "realId" : 11 // HERE WRONG ORDER
        },
        "sort" : [
          "11"
        ]
      },
      {
        "_index" : "lookup__20190904_0723",
        "_type" : "_doc",
        "_id" : "attribute/110",
        "_score" : null,
        "_source" : {
          "realId" : 110
        },
        "sort" : [
          "110"
        ]
      },
      {
        "_index" : "lookup__20190904_0723",
        "_type" : "_doc",
        "_id" : "attribute/111",
        "_score" : null,
        "_source" : {
          "realId" : 111
        },
        "sort" : [
          "111"
        ]
      }
    ]
  }
}

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.