CDRH / api

Codenamed "Apium": An API to access all public Center for Digital Research in the Humanities resources
https://cdrhdev1.unl.edu/api_frontend
MIT License
3 stars 1 forks source link

Sorting #15

Closed jduss4 closed 7 years ago

jduss4 commented 7 years ago

At the moment the API Spec lists the following two fields for /items

sort  =>    field to sort ascending
sort_desc =>   field to sort descending

This means it would be possible for conflicting parameters to come in:

?sort=field&sort_desc=field

For now what we are thinking that it may work something like this

sort => field to sort (default ascending except when query string exists)
desc => whether sort is descending or ascending, depending on param value

Originally we thought if desc was present, then always descending, but we will need a way to override that if there is a query string. It makes sense that query strings would default to descending for the search results (relevance / score), but sometimes people might want to sort the reverse? Is this a large enough usecase that we should design for it?

jduss4 commented 7 years ago

We have determined that in order to accommodate multiple sorts, it will look something like this:

sort[]=field1+asc&sort[]=field2+desc

The separator character will need to be chosen and should be the same as whatever we use for f[]