Implement proper casing for Explore quick filters using sourceFields
Problem
Explore quick filters are currently displaying values in lowercase for entity types, domains, owners, and other aggregation-based filters. This creates a poor user experience as the proper casing is not preserved.
Solution
Backend support is already available via the aggregate API's sourceFields parameter (implemented in #20734). This adds a top_hits sub-aggregation that returns original-cased values from _source.
The Advanced Search query builder already uses this pattern successfully - see AdvancedSearchClassBase.ts:821 where it passes sourceFields: 'name' and parseBucketsData in SearchUtils.tsx:346 reads the original case from top_hits#top.
Implementation Steps
- For entity types: Handle on UI side directly (can be done without backend changes)
- For domains, owners, and other filters:
- In ExploreQuickFilters.tsx, when calling getAggregationOptions (~line 118), pass sourceFields for the field being queried:
- "domains.displayName" for domains
- "owners.displayName" for owners
- Similar patterns for other fields
- In getOptionsFromAggregationBucket (AdvancedSearchUtils.tsx:371), instead of using bucket.key as the label, read the original value from
bucket['top_hits#top'].hits.hits[0]._source - Can reuse or follow the pattern from parseBucketsData function (SearchUtils.tsx:346)
- In ExploreQuickFilters.tsx, when calling getAggregationOptions (~line 118), pass sourceFields for the field being queried:
Technical Context
The .keyword fields are indexed as lowercase (via lowercase_normalizer) so matching/filtering works case-insensitively, but _source always stores the original case. We aggregate on the lowercase .keyword for matching, and read the display value from _source via top_hits sub-aggregation to get proper case back.
Internal Reference
Slack thread: https://collate-inc.slack.com/archives/C09K5QBGG1J/p1774440697305259
@harshach , I would love to work on this. Could you plz assign this to me?
@kris70lesgo make sure to have unit tests and playwright tests for this
@harshach , I’d love to take this one on. Preserving the proper casing in the quick filters will definitely make the UI look much cleaner and improve the overall UX.
Since the backend support is already merged via #20734, my approach will focus entirely on the UI adjustments:
Entity Types: I will handle the proper casing directly on the UI side since this doesn't strictly require a backend payload change.
Domains, Owners, & Others: I'll update the getAggregationOptions call in ExploreQuickFilters.tsx to pass the appropriate sourceFields (like "domains.displayName" or "owners.displayName").
Parsing the Buckets: I'll update getOptionsFromAggregationBucket in AdvancedSearchUtils.tsx to mimic the pattern already working in parseBucketsData. Instead of defaulting to bucket.key (the lowercased .keyword), I'll extract the display label from bucket['top_hits#top'].hits.hits[0]._source to get the original casing back.
Could you assign this issue to me? I'll get a PR up shortly!