-
Notifications
You must be signed in to change notification settings - Fork 179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sort Extension: simple format for GET #513
Changes from 12 commits
978cb46
b6e0419
0926ddf
cf4eccb
96becab
bb5b79a
b026bb7
1d36739
197a6bf
9085b58
58c15ab
fbf3f40
68678f1
ec19f7a
17bf0e6
3f8d9eb
125d3bc
5909580
dd3c040
d6aebcf
7695ce3
dba1ac1
248893e
e58f0aa
fee3794
127c7c9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,29 @@ | |
|
||
**Extension [Maturity Classification](../../../extensions/README.md#extension-maturity): Pilot** | ||
|
||
The STAC search endpoint, `/stac/search`, by default returns results in descending order using the datetime property. The sort API extension adds a new parameter, `sort` that allows the user to define fields to sort results by. Only properties may be used to sort results. The syntax for the `sort` parameter is: | ||
By default, the STAC search endpoint `/stac/search` returns results in no specified order. Whatever order the results are in is up to the implementor, and will typically default to an arbitrary that is fastest for the underlying data store to retrieve results. | ||
|
||
The Sort API Extension adds a new field, `sort`, that allows the user to define fields by which to sort results. Only string, numeric, and datetime attributes of Item (`id` and `collection` only) or Item Properties (any attributes) may be used to sort results. It is not required that implementations support sorting over all attributes, but implementations should return an error when attempting to sort over a field that does not support sorting. | ||
|
||
Two values for direction are supported: "asc" (ascending) or "desc" (descending). If the direction is not specified, the value is ascending. The `sort` value is an array, so multiple sort fields can be defined which will be used to sort the data in the order provided (e.g., first by `datetime`, then by `eo:cloud_cover`). | ||
|
||
## GET or POST Form | ||
|
||
When calling `/stac/search` using GET or POST with `Content-Type: application/x-www-form-urlencoded` or `Content-Type: multipart/form-data`, the semantics are the same, except the syntax is a single parameter `sort` with a comma-separated list of "<name>|<direction>" definitions. The sort order must be specified. | ||
|
||
Examples of `sort` parameter: | ||
|
||
GET /stac/search?sort=created|asc,id|desc | ||
|
||
GET /stac/search?sort=eo:cloud_cover|desc | ||
|
||
GET /stac/search?sort=created | ||
|
||
# POST JSON Entity | ||
|
||
When calling `/stac/search` using POST with`Content-Type: application/json`, this extension adds an attribute `sort` with an object value to the core JSON search request body. If no direction is specified, the default is ascending. | ||
|
||
The syntax for the `sort` attribute is: | ||
|
||
```json | ||
{ | ||
|
@@ -15,4 +37,21 @@ The STAC search endpoint, `/stac/search`, by default returns results in descendi | |
} | ||
``` | ||
|
||
where <direction> is either "asc" (ascending) or "desc" (descending). The `sort` value is an array, so multiple sort fields can be defined which will be used to sort the data in the order provided (e.g., first by `datetime`, then by `eo:cloud_cover`). | ||
```json | ||
{ | ||
"sort": [ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Borrowing from OGC approaches, what about: "sort": [
{
"property": "created",
"order": "asc"
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @tomkralidis can you point me to the documentation for those OGC approaches? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
{ | ||
"field": "created", | ||
"direction": "asc" | ||
}, | ||
{ | ||
"field": "id", | ||
"direction": "desc" | ||
}, | ||
{ | ||
"field": "collection" | ||
} | ||
] | ||
} | ||
``` | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about replacing
|
with;
? LikeGET /stac/search?sort=eo:cloud_cover;desc
.|
may be ambiguous (expressing this or that property, say)