Sorting By Indexed Fields

    When creating the index with FT.CREATE, you can declare 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 followig schema:

    The fields and age 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 behavior. This means that 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 sortabl field defined in the schema.