feat(persistence): honor _sort and add :missing/:not on PostgreSQL; reconcile search matrix#118
Open
smunini wants to merge 1 commit into
Open
feat(persistence): honor _sort and add :missing/:not on PostgreSQL; reconcile search matrix#118smunini wants to merge 1 commit into
smunini wants to merge 1 commit into
Conversation
…econcile search matrix Audited FHIR Search against build.fhir.org/search.html and found the Backend Capability Matrix stale in both directions, plus one functional bug. - PostgreSQL search now honors `query.sort` on the first-page and offset paths (`_id`/`_lastUpdated`) instead of hardcoding `ORDER BY last_updated DESC`. SQLite had the same latent bug (its `build_order_by` helper was only used in unit tests); wired into both backends. Cursor/keyset pages keep the default ordering, and the no-`_sort` default ordering is unchanged (no paging regression). - PostgreSQL now supports the `:missing` (type-agnostic) and `:not` (token) search modifiers, mirroring SQLite. - Reconciled the capability matrix and contradicting prose: downgraded overstated cells (ES composite, ES/SQLite/PG :above/:below URI-only, Mongo multi-field sort) and upgraded understated ones (PG chained/_has/_text/ _content, Mongo :exact/:contains). - Added docs/search-spec-assessment.md: a capability-by-capability assessment vs. the spec with the REST/backend boundary and a roadmap of known gaps. Tests: new PostgreSQL integration tests for `_sort`, `:missing`, and `:not`.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
Audited HFS FHIR Search against the spec. The Backend Capability Matrix in
crates/persistence/README.mdwas stale in both directions, and one discrepancy was a real functional bug: PostgreSQL claimed full_sortsupport but ignoredquery.sortand hardcodedORDER BY last_updated DESC, id DESC.Changes
Code
_sort— addedPostgresQueryBuilder::build_order_byand wired it into the first-page and offset search paths. SQLite had the same latent bug (itsbuild_order_bywas only exercised by unit tests), so it's wired in there too for parity. The no-_sortdefault ordering is byte-identical to before — no pagination regression; cursor/keyset pages keep the default ordering (a pre-existing constraint, now documented).:missing/:not—:missingresolves from presence/absence of asearch_indexentry;:not(token) negates the match and correctly includes resources with no value. Mirrors SQLite.Docs
:above/:below◐ for URI-only, Mongo multi-field sort ◐) and upgraded understated ones (PG chained/_has/_text/_content✓, Mongo:exact/:contains✓, PG:not/:missing✓). Added clarifying notes and fixed contradicting prose.crates/persistence/docs/search-spec-assessment.md: capability-by-capability assessment vs. the spec, the REST/backend boundary, and a roadmap of remaining gaps.Tests
New PostgreSQL integration tests:
_sort(asc/desc),:missing(true/false),:not(incl. resources with no value). Full PG search suite + SQLite suite pass;clippy -D warningsclean.Remaining gaps (documented, not in this PR)
Sort by arbitrary search parameter (all backends), PG composite +
:of-type/:text-advanced, ES real composite components + chaining, MongoDB native search gaps, and minor REST result params (_maxresults,_score,first/lastlinks).