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

**URL:** <https://discuss.elastic.co/t/not-able-to-sort-on-long-field-and-function-score-also-not-working/328077>\
**Category:** Elasticsearch\
**Created:** [March 20, 2023, 1:22pm UTC](https://discuss.elastic.co/t/not-able-to-sort-on-long-field-and-function-score-also-not-working/328077 "2023-03-20T13:22:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rakhshunda\_Noorein\_J](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rakhshunda_noorein_j/32/99407_2.png) [@Rakhshunda\_Noorein\_J](https://discuss.elastic.co/u/Rakhshunda_Noorein_J)\
**Post date:** [March 20, 2023, 1:22pm UTC](https://discuss.elastic.co/t/not-able-to-sort-on-long-field-and-function-score-also-not-working/328077/1 "2023-03-20T13:22:29Z")

</div>

Hello,

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

```auto
{
    "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.

```auto
{
                "_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
                ]
            }

```

---

<div class="post-metadata">

**Author:** ![RabBit\_BR](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rabbit_br/32/82261_2.png) [@RabBit\_BR](https://discuss.elastic.co/u/RabBit_BR)\
**Post date:** [March 20, 2023, 1:27pm UTC](https://discuss.elastic.co/t/not-able-to-sort-on-long-field-and-function-score-also-not-working/328077/2 "2023-03-20T13:27:15Z")

</div>

Hi @Rakhshunda_Noorein_J

The "Sort\_field" is float. My suggestion is change type to float in your mapping.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [April 17, 2023, 1:27pm UTC](https://discuss.elastic.co/t/not-able-to-sort-on-long-field-and-function-score-also-not-working/328077/3 "2023-04-17T13:27:21Z")

</div>

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