Not able to sort on Long field and Function score also not working

Hello,

I am performing a simple query and sorting on a field (Long Type). It is not sorting.

{
    "from":0,
    "size": 5000,
    "query" : {
        "match_all" : {}
    },
    "sort":[
        {
        "sort_field":  {"order" : "desc"}
        }
    ]
}

sort_field with 0 is coming first than sort_field with 0.258...

e.g.

{
                "_index": "index1",
                "_id": "12",
                "_score": null,
                "_source": {
                 "Name" : Mango,
                "Sort_field": 0
                },
                "sort": [
                    0
                ]
            },
            {
                "_index": "index1",
                "_id": "64",
                "_score": null,
                "_source": {
                "_source": {
                 "Name" : Banana,
                "Sort_field": 0.258
                },
                "sort": [
                    0
                ]
            }

Hi @Rakhshunda_Noorein_J

The "Sort_field" is float. My suggestion is change type to float in your mapping.

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