1- # STAC API - Sort Extension
1+ # STAC API - Sort Extension Specification
22
3+ - [ STAC API - Sort Extension Specification] ( #stac-api---sort-extension-specification )
4+ - [ Overview] ( #overview )
5+ - [ HTTP GET (or POST Form)] ( #http-get-or-post-form )
6+ - [ HTTP POST JSON Entity] ( #http-post-json-entity )
7+
8+ ## Overview
9+
10+ - ** Title:** Sort
311- ** OpenAPI specification:** [ openapi.yaml] ( openapi.yaml )
4- - ** Conformance Classes:**
12+ - ** Conformance Classes:**
513 - ** STAC API - Item Search** binding: < https://api.stacspec.org/v1.0.0-rc.2/item-search#sort >
614 - ** STAC API - Features** binding: < https://api.stacspec.org/v1.0.0-rc.2/ogcapi-features#sort >
7- - ** Extension [ Maturity Classification] ( https://github.com/radiantearth/stac-api-spec/blob/main/README.md#maturity-classification ) :** Candidate
15+ - ** Scope:** STAC API - Features, STAC API - Item Search
16+ - ** [ Extension Maturity Classification] ( https://github.com/radiantearth/stac-api-spec/tree/main/README.md#maturity-classification ) :** Candidate
817- ** Dependencies:**
918 - [ STAC API - Item Search] ( https://github.com/radiantearth/stac-api-spec/tree/v1.0.0-rc.2/item-search )
1019 - [ STAC API - Features] ( https://github.com/radiantearth/stac-api-spec/tree/v1.0.0-rc.2/item-search )
11-
20+ - ** Owner** : @philvarner
21+
1222This specification defines a new parameter, ` sortby ` , that allows the user to define the fields by which
13- to sort results.
14- Only string, numeric, and datetime attributes of Item (` id ` and ` collection ` only) or Item Properties (any attributes)
23+ to sort results.
24+ Only string, numeric, and datetime attributes of Item (` id ` and ` collection ` only) or Item Properties (any attributes)
1525may be used to sort results.
1626
17- It is not required that implementations support sorting over all attributes, but
27+ It is not required that implementations support sorting over all attributes, but
1828implementations should return a 400 Bad Request status code when attempting to sort over a field name that does
1929not support sorting.
2030This specification does not yet require the implementation of an "-ables" endpoint (like CQL2 does for queryables)
@@ -23,25 +33,25 @@ fields that can be sorted over, so implementations must provide this out-of-band
2333fields in Item Properties to be prefixed with ` properties. ` or not, or support use of both the prefixed and non-prefixed
2434name, e.g., ` properties.datetime ` or ` datetime ` .
2535
26- Sort behavior may be bound to either or both of
36+ Sort behavior may be bound to either or both of
2737[ STAC API - Item Search] ( https://github.com/radiantearth/stac-api-spec/tree/v1.0.0-rc.2/item-search ) (` /search ` endpoint) or
2838[ STAC API - Features] ( https://github.com/radiantearth/stac-api-spec/tree/v1.0.0-rc.2/ogcapi-features )
29- (` /collections/{collectionId}/items ` endpoint) by advertising the relevant conformance class.
39+ (` /collections/{collectionId}/items ` endpoint) by advertising the relevant conformance class.
3040
31- Fields may be sorted in ascending or descending order. The syntax between GET requests and POST requests with a JSON
32- body vary. The ` sortby ` value is an array, so multiple sort fields can be defined which will be used to sort
41+ Fields may be sorted in ascending or descending order. The syntax between GET requests and POST requests with a JSON
42+ body vary. The ` sortby ` value is an array, so multiple sort fields can be defined which will be used to sort
3343the data in the order provided (e.g., first by ` datetime ` , then by ` eo:cloud_cover ` ).
3444
35- ** NOTE** : * This specification may change, as our goal is to align with OGC API functionality, and sorting is currently being
36- worked on as part of OGC API - Records, see [ this issue] ( https://github.com/opengeospatial/ogcapi-records/issues/22 )
45+ ** NOTE** : * This specification may change, as our goal is to align with OGC API functionality, and sorting is currently being
46+ worked on as part of OGC API - Records, see [ this issue] ( https://github.com/opengeospatial/ogcapi-records/issues/22 )
3747for the latest discussion.*
3848
3949## HTTP GET (or POST Form)
4050
41- When calling a relevant endpoint using GET (or POST with ` Content-Type: application/x-www-form-urlencoded ` or
42- ` Content-Type: multipart/form-data) ` , a single parameter ` sortby ` with a comma-separated list of item field names must
43- be provided. The field names may be prefixed with either "+" for ascending, or "-" for descending. If no sign is
44- provided before the field name, it will be assumed to be "+".
51+ When calling a relevant endpoint using GET (or POST with ` Content-Type: application/x-www-form-urlencoded ` or
52+ ` Content-Type: multipart/form-data) ` , a single parameter ` sortby ` with a comma-separated list of item field names must
53+ be provided. The field names may be prefixed with either "+" for ascending, or "-" for descending. If no sign is
54+ provided before the field name, it will be assumed to be "+".
4555
4656Examples of ` sortby ` parameter:
4757
@@ -50,12 +60,12 @@ Examples of `sortby` parameter:
50603 . ` GET /search?sortby=properties.created,-id `
51614 . ` GET /search?sortby=+properties.created,-id `
52625 . ` GET /search?sortby=-properties.eo:cloud_cover `
53-
63+
5464Note that examples 1 and 2 are symantically equivalent, as well as examples 3 and 4.
5565
5666## HTTP POST JSON Entity
5767
58- When calling the relevant endpoint using POST with` Content-Type: application/json ` , this adds an attribute ` sortby ` with
68+ When calling the relevant endpoint using POST with` Content-Type: application/json ` , this adds an attribute ` sortby ` with
5969an object value to the core JSON search request body.
6070
6171The syntax for the ` sortby ` attribute is:
0 commit comments