Skip to content

Commit

Permalink
Fix bug extracting totalResults
Browse files Browse the repository at this point in the history
  • Loading branch information
nonword committed May 24, 2024
1 parent 45dc7ca commit ef3d5a0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/jsonld_serializers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
Expand Down

0 comments on commit ef3d5a0

Please sign in to comment.