<commit_before>[[search-request-sort]]
=== Sort

Allows to add one or more sort on specific fields. Each sort can be
reversed as well. The sort is defined on a per field level, with special
field name for `_score` to sort by score.

[source,js]
--------------------------------------------------
{
    "sort" : [
        { "post_date" : {"order" : "asc"}},
        "user",
        { "name" : "desc" },
        { "age" : "desc" },
        "_score"
    ],
    "query" : {
        "term" : { "user" : "kimchy" }
    }
}
--------------------------------------------------

==== Sort Values

The sort values for each document returned are also returned as part of
the response.

==== Sort mode option<commit_msg>Spelling out the sort order options<commit_after>[[search-request-sort]]
=== Sort

Allows to add one or more sort on specific fields. Each sort can be
reversed as well. The sort is defined on a per field level, with special
field name for `_score` to sort by score.

[source,js]
--------------------------------------------------
{
    "sort" : [
        { "post_date" : {"order" : "asc"}},
        "user",
        { "name" : "desc" },
        { "age" : "desc" },
        "_score"
    ],
    "query" : {
        "term" : { "user" : "kimchy" }
    }
}
--------------------------------------------------

==== Sort Values

The sort values for each document returned are also returned as part of
the response.

==== Sort Order

The `order` option can have the following values:

[horizontal]
`asc`:: Sort in ascending order
`desc`:: Sort in descending order

The order defaults to `desc` when sorting on the `_score`, and defaults
to `asc` when sorting on anything else.

==== Sort mode option
{'fraction_non_alphanumeric': 0.23512080141426045, 'fraction_numerical': 0.0, 'mean_word_length': 1.839464882943144, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '359072', 'n_tokens_mistral': 482, 'n_tokens_neox': 471, 'n_words': 190}