gbv / jskos-server

Web service to access JSKOS data
https://coli-conc.gbv.de/api/
MIT License
6 stars 4 forks source link

/voc sorting: Add `order` parameter #137

Closed stefandesu closed 3 years ago

stefandesu commented 3 years ago

There is no way to choose which order (ascending or descending) schemes should be sorted when using the sort parameter. We should add an order parameter like for /mappings.

118

stefandesu commented 3 years ago

Not sure why I haven't discovered this before, but MongoDB's indexes are not lexical, i.e. if we have an index on a field and we sort using this field, it's going to use the number representation of the letters. This sorts uppercase letters before lowercase letters, for example.

One solution would be to use a Case Insensitive Index: https://docs.mongodb.com/manual/core/index-case-insensitive/

In any case, having proper behavior with this will require reindexing those fields after the version upgrade.

nichtich commented 3 years ago

Sorting by date of creation and by date of modification should be enough to start with.

stefandesu commented 3 years ago

Sorting by date of creation and by date of modification should be enough to start with.

Well, we already have sorting by label and notation (and especially the former makes a lot of sense to me), but I only just noticed that it wouldn't work properly. I have an idea how to get around it without adding new indexes.

stefandesu commented 3 years ago

I added a bunch of changes to mitigate the issues:

I also added a piece of upgrade code which can be executed via npm run upgrade that regenerates those keywords for all schemes.

I'm going to look for other small things that could be included in a release, but then I'd release version 1.2.2.