Associated records / Align related records API filtering with associated records - #9437
Open
juanluisrp wants to merge 2 commits into
Open
Associated records / Align related records API filtering with associated records#9437juanluisrp wants to merge 2 commits into
juanluisrp wants to merge 2 commits into
Conversation
…ted records Related records are retrieved through MetadataUtils.getRelated. Align this code path with the getAssociated implementation and the main search by building its Elasticsearch queries with the shared EsFilterBuilder filtering: thread the ServiceContext through the private search and calculateResults helpers and combine the portal filter with the standard search filter. Administrators are unaffected as the filter resolves to `*:*`. Add RelatedApiIntegrationTest covering anonymous and administrator access.
juanluisrp
force-pushed
the
fix/related-records-view-filter-main
branch
from
July 21, 2026 08:04
58f4134 to
3ad12e1
Compare
…ted records - Avoid redundant filter computation. - Escape portal filter.
|
josegar74
approved these changes
Jul 21, 2026
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.


Summary
Related records are retrieved through
MetadataUtils.getRelated. This aligns that code path with thegetAssociatedimplementation and the main search by building its Elasticsearch queries with the sharedEsFilterBuilderfiltering.The
ServiceContextis threaded through the privatesearch/calculateResultshelpers, and the portal filter is combined with the standard search filter, so related-records results are built the same way as the rest of the catalog search. Administrators are unaffected (the filter resolves to*:*).Affected endpoints:
GET /api/records/{uuid}/relatedGET /api/relatedChanges
MetadataUtils.search(...)andMetadataUtils.calculateResults(...)now receive theServiceContextand reuse the shared search filter, combined with the portal filter when present.getRelated(...)updated to pass the context.RelatedApiIntegrationTest.How to test
Requires a running Elasticsearch instance (see
es/docker-compose.yml).Manual check: relate two records with different privileges, then request the related resources. The listing reflects the current user's view privileges (an administrator sees all; an anonymous user sees only the ones they are allowed to view).