Skip to content

Set default sort order on IIIF collection searches#351

Merged
kdid merged 1 commit intodeploy/stagingfrom
collection-iiif-order-bug
Mar 18, 2026
Merged

Set default sort order on IIIF collection searches#351
kdid merged 1 commit intodeploy/stagingfrom
collection-iiif-order-bug

Conversation

@kdid
Copy link
Copy Markdown
Contributor

@kdid kdid commented Mar 16, 2026

Sumamry

Fix duplicate items in paginated IIIF collection responses

When requesting pages of a IIIF collection (e.g. ?as=iiif&page=2), items would sometimes appear on multiple pages. Because all works matching collection.id:{id} receive equal relevance scores, OpenSearch returned them in an arbitrary shard-merge order that was not guaranteed to be stable between requests.

The fix applies a default accession_number:asc sort to IIIF collection searches. This is done via a new defaultSort option on doSearch that is applied to the search context after query construction but before the OpenSearch request - keeping it out of query string parameters and pagination URLs, and leaving all other search paths unaffected. An explicit ?sort= parameter from the caller will still take precedence.

To test/verify

Using the tool: https://nulib-labs.github.io/debug-dcapi-paging/

@kdid kdid self-assigned this Mar 16, 2026
@kdid kdid requested a review from mathewjordan March 16, 2026 18:55
Copy link
Copy Markdown
Member

@mathewjordan mathewjordan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great and works well for me!

@kdid kdid merged commit 0790408 into deploy/staging Mar 18, 2026
1 check passed
@kdid kdid deleted the collection-iiif-order-bug branch March 18, 2026 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants