gbv / jskos-server

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

GET /mappings: Make sure sort order is always stable #190

Closed stefandesu closed 1 year ago

stefandesu commented 1 year ago

I found out that sorting in MongoDB is not stable if the field by which result are sorted can contain duplicate values. In order to create a true stable sort, we need to additionally sort by the _id field because it's the only one that's always unique. This requires new compound indexes.

stefandesu commented 1 year ago

I've decided to additionally sort by source concept, i.e. results are first sorted by the sort field (modified by default), then by source concept URI, then by _id. When looking at one of our old concordances in Cocoda which don't have a date associated with them, we can have a nice sort by source concept. Of course sorting by URI is not always optimal, but should work fine in most cases, and it's only relevant if the date is not unique.