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() } }