Sorting

Overview

Examples

Below is example of sorting configuration:

{
    "defaults": {
        "sort": "most_votes"
    },
    "sortings": {
        "most_votes": {
            "title": "Most votes",
            "type": "normal",
            "order": "desc",
            "field": "votes"
        },
        "nearest_hotels": {
            "title": "Nearest locations",
            "type": "geo",
            "order": "asc",
            "field": "geo"
        }
    }
}

You need to provide sort key if you want to sort items i.e. /api/v1/cities?sort=nearest_hotels. If you don't provide sort key it will take default one most_votes

If you don't provide defaults sort it will make default elasticsearch sorting

Sorting result example
Was this page helpful ?