Sorting by Indexed Fields

    When creating the index with , you can declare TEXT and NUMERIC properties to be SORTABLE . When a property is sortable, we can later decide to order the results by its values. For example, in the following schema:

    The fields last_name and are sortable, but first_name isn’t. This means we can search by either first and/or last name, and sort by last name or age.

    Also, note that text fields get normalized and lowercased in a Unicode-safe way when stored for sorting and currently there is no way to change this behaviour. This means that America and america are considered equal in terms of sorting.

    If an index includes sortable fields, you can add the SORTBY parameter to the search request (outside the query body), and order the results by it. This overrides the scoring function mechanism, and the two cannot be combined. If is specified along with SORTBY , the scores returned are simply the relative position of each result in the result set.

    • field_name must be a sortable field defined in the schema.