code: def serialize_search(self, pid_fetcher, search_result, links=None,
                           item_links_factory=None, **kwargs):
          
          return json.dumps(dict(
              hits=dict(
                  hits=[self.transform_search_hit(
                      pid_fetcher(hit['_id'], hit['_source']),
                      hit,
                      links_factory=item_links_factory,
                      **kwargs
                  ) for hit in search_result['hits']['hits']],
                  total=search_result['hits']['total'],
              ),
              links=links or {},
              aggregations=search_result.get('aggregations', dict()),
          ), **self._format_args())
docs: Serialize a search result.
  
          :param pid_fetcher: Persistent identifier fetcher.
          :param search_result: Elasticsearch search result.
          :param links: Dictionary of links to add to response.