diff --git a/apps/server-asset-sg/src/features/assets/search/asset-search.service.ts b/apps/server-asset-sg/src/features/assets/search/asset-search.service.ts index a9d785fc..c9d5f340 100644 --- a/apps/server-asset-sg/src/features/assets/search/asset-search.service.ts +++ b/apps/server-asset-sg/src/features/assets/search/asset-search.service.ts @@ -310,15 +310,16 @@ export class AssetSearchService { value: bucket.key, count: bucket.doc_count, }); + console.log(JSON.stringify(aggs, null, 2)); return { total, - assetKindItemCodes: aggs.assetKindItemCodes.a.buckets.map(mapBucket), - authorIds: aggs.authorIds.a.buckets.map(mapBucket), - languageItemCodes: aggs.languageItemCodes.a.buckets.map(mapBucket), - geometryCodes: aggs.geometryCodes.a.buckets.map(mapBucket), - manCatLabelItemCodes: aggs.manCatLabelItemCodes.a.buckets.map(mapBucket), - usageCodes: aggs.usageCodes.a.buckets.map(mapBucket), - workgroupIds: aggs.workgroupIds.a.buckets.map(mapBucket), + assetKindItemCodes: aggs.assetKindItemCodes?.a?.buckets?.map(mapBucket) ?? [], + authorIds: aggs.authorIds?.a?.buckets?.map(mapBucket) ?? [], + languageItemCodes: aggs.languageItemCodes?.a?.buckets?.map(mapBucket) ?? [], + geometryCodes: aggs.geometryCodes?.a?.buckets?.map(mapBucket) ?? [], + manCatLabelItemCodes: aggs.manCatLabelItemCodes?.a?.buckets?.map(mapBucket) ?? [], + usageCodes: aggs.usageCodes?.a?.buckets?.map(mapBucket) ?? [], + workgroupIds: aggs.workgroupIds?.a?.buckets?.map(mapBucket) ?? [], createDate: { min: dateFromDateId(aggs.minCreateDate.a.value), max: dateFromDateId(aggs.maxCreateDate.a.value),