Skip to content

Use case-insensitive collation as default for Mongo pagination#25808

Open
dennisoelkers wants to merge 5 commits intomasterfrom
case-insensitive-pagination-sorting
Open

Use case-insensitive collation as default for Mongo pagination#25808
dennisoelkers wants to merge 5 commits intomasterfrom
case-insensitive-pagination-sorting

Conversation

@dennisoelkers
Copy link
Copy Markdown
Member

@dennisoelkers dennisoelkers commented Apr 24, 2026

Description

Adds a default case-insensitive, numeric-aware Collation to DefaultMongoPaginationHelper and uses it whenever a caller does not supply its own collation. PaginatedStreamService drops its manual $toLower pipeline stages in favor of the shared collation.

Motivation and Context

Case-insensitive sorting was previously bolted onto PaginatedStreamService by projecting a lowercased copy of the sort field through an aggregation pipeline. Other paginated endpoints had no case-insensitive sorting at all. Centralizing a sensible default collation removes the per-call workaround and makes sort order consistent across paginated APIs. numericOrdering additionally gives natural ordering for titles containing numbers (e.g. Stream 2 before Stream 10).

Fixes Graylog2/graylog-plugin-enterprise#12877

How Has This Been Tested?

Manual verification against the streams listing API. Existing DefaultMongoPaginationHelperTest / …WithPipelineTest still pass.

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Refactoring (non-breaking change)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have requested a documentation update.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.

Adds a default case-insensitive collation to DefaultMongoPaginationHelper
so callers get case-insensitive, numeric-aware sorting without
per-query workarounds. PaginatedStreamService drops its manual
$toLower field transformation in favor of the shared collation.
@dennisoelkers dennisoelkers force-pushed the case-insensitive-pagination-sorting branch from 399a78f to 3d0ffd3 Compare April 24, 2026 11:32
…collation

Filter cases now use `_id` so the string collation does not widen the match
set, and the sort cases expect upper/lower case entries to be interleaved
with `_id` ASC breaking ties regardless of sort direction.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@dennisoelkers dennisoelkers added the e2e-tests Run PR build with e2e tests. label Apr 27, 2026
@dennisoelkers dennisoelkers requested a review from thll May 4, 2026 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

e2e-tests Run PR build with e2e tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant