From ef3d5a0454fc3d48a71bdc85784d6435c9b161f1 Mon Sep 17 00:00:00 2001 From: Paul Beaudoin Date: Fri, 24 May 2024 14:01:11 -0400 Subject: [PATCH] Fix bug extracting totalResults --- lib/jsonld_serializers.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/jsonld_serializers.js b/lib/jsonld_serializers.js index 5517223b..de4c759a 100644 --- a/lib/jsonld_serializers.js +++ b/lib/jsonld_serializers.js @@ -401,7 +401,8 @@ class ResourceResultsSerializer extends SearchResultsSerializer { static serialize (resp, opts) { const results = resp.hits.hits.map((h) => ({ score: h._score, record: ResourceSerializer.serialize(h._source) })) - opts = Object.assign({ extraRootProperties: { totalResults: resp.hits.total?.value || resp.hits.total } }, opts) + const totalResults = typeof resp.hits.total?.value === 'number' ? resp.hits.total.value : resp.hits.total + opts = Object.assign({ extraRootProperties: { totalResults } }, opts) return (new ResourceResultsSerializer(results, opts)).format() } }