Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,11 @@ export function withAggregations() {
},

setAggregationExpanded(key: string, expanded: boolean): void {
const aggregations = store.aggregations().map((agg) =>
agg.key === key ? { ...agg, expanded } : agg,
);
const aggregations = store.aggregations().map((agg) => {
if (agg.key !== key) return agg;
if (expanded) return { ...agg, expanded };
return { ...agg, expanded, loaded: false, value: { ...agg.value, buckets: [] } };
});
patchState(store, { aggregations });
},

Expand Down Expand Up @@ -171,6 +173,7 @@ export function withAggregations() {
type: esAggregation.type || aggregation.type || 'terms',
config: esAggregation.config || aggregation.config,
name: aggregation.name || esAggregation.name,
included: true,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Do not unconditionally mark enriched aggregations as included.

This overwrites included: false for closed aggregations returned by Elasticsearch. Since facetsParameter uses included to decide which aggregations to request, this can cause closed facets to be included in subsequent searches; the supplied spec explicitly expects enriched closed aggregations to remain false. Preserve the existing state or derive inclusion from the specific request that triggered enrichment.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@projects/rero/ng-core/src/lib/record/component/search/store/features/with-aggregations.feature.ts`
at line 174, Update the enriched aggregation handling around the included field
so it does not unconditionally set included to true. Preserve the existing
included state, or derive it from the request that triggered enrichment,
ensuring closed aggregations remain false and facetsParameter excludes them from
subsequent searches.

value: {
...aggregation.value,
buckets: esAggregation.buckets || aggregation.value.buckets,
Expand Down