openreferral / api-specification

This is the working repository for Open Referral's Human Services Data API protocols.

Home Page:https://openreferral.readthedocs.io/en/latest/hsda/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Sorting

kinlane opened this issue · comments

How will we be sorting information. There is no sorting capability in the current design.

We need at least Alphabetical and Proximity (if a search reference location is included). A third option is Relevance which opens a big can of worms about how relevance is calculated. We could just keep that can closed for now though, leave it as a sorting option, and let each implementer decide how to calculate and sort via Relevance.

A last-updated (descending) sort will be important for synchronisation use-cases.

Suggesting we run with

sortby ([fieldname],last-updated)
order (asc,desc)

leaving proximity for futue release, and possibility limited to HSDA search.

combinging simplicity, best practices, and above feedback.

Would this only allow sorting by fields in the top resource? Or would we allow a syntax of field paths to access sub-resources in the /full / /complete representations (or even when /complete is not requested)?

For example, I might want to search for organizations, but sort the results based on thee funding source of their services.

Could this be expressed as:

?sortby=organizations/services/funding/source&order=asc

with this release I kept just top level. Plan is to go next level with next release. Trying to minimize the change. Thanks for brining up!

A possible alternative to the order parameter is an optional - prefix on each of the fields passed to sortby, that way it's possible to sort ascending by one field and descending by another. Not sure if this is functionality that is useful or just making things more complicated.

@rasmus-storjohann-PG I like that concept. Will be evaluating.

Keeping single parameter order by as the default, and will be adding robust search capabilities to /search.

      - in: query
        name: sort_by
        description: Which field to sort by.
        schema:
          type: string
      - in: query
        name: order
        description: Which order to sort by (asc,desc).
        schema:
          type: string