# Painless sort not working in call cases on 8.12.0?

**URL:** <https://discuss.elastic.co/t/painless-sort-not-working-in-call-cases-on-8-12-0/351414>\
**Category:** Elasticsearch\
**Tags:** painless\
**Created:** [January 19, 2024, 7:51am UTC](https://discuss.elastic.co/t/painless-sort-not-working-in-call-cases-on-8-12-0/351414 "2024-01-19T07:51:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ilgrosso](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ilgrosso/32/94485_2.png) [@ilgrosso](https://discuss.elastic.co/u/ilgrosso)\
**Post date:** [January 19, 2024, 7:51am UTC](https://discuss.elastic.co/t/painless-sort-not-working-in-call-cases-on-8-12-0/351414/1 "2024-01-19T07:51:14Z")

</div>

The following is working as expected up to 8.11.4:

```json
    "sort": [
          {
            "_script": {
                "order": "asc",
                "script": {
                    "lang": "painless",
                    "source": "doc['fullPath'].value.chars().filter(ch -> ch == '/').count()"
                },
                "type": "number"
            }
        }
    ]

```

where `fullPath` is a field containing UNIX-path like values.

After upgrading to 8.12.0, results are not sorted anymore.

FTR a simple

```json
    "sort": [
       { "fullPath" : "asc" }
    ]

```

or

```json
    "sort": [
          {
            "_script": {
                "order": "asc",
                "script": {
                    "lang": "painless",
                    "source": "doc['fullPath'].value.length()"
                },
                "type": "number"
            }
        }
    ]

```

still work as expected.

---

<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:** [February 16, 2024, 7:51am UTC](https://discuss.elastic.co/t/painless-sort-not-working-in-call-cases-on-8-12-0/351414/2 "2024-02-16T07:51:17Z")

</div>

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