code: def preprocess_search_hit(pid, record_hit, links_factory=None, **kwargs):
          
          links_factory = links_factory or (lambda x, **k: dict())
          record = dict(
              pid=pid,
              metadata=record_hit['_source'],
              links=links_factory(pid, record_hit=record_hit, **kwargs),
              revision=record_hit['_version'],
              created=None,
              updated=None,
          )
          # Move created/updated attrs from source to object.
          for key in ['_created', '_updated']:
              if key in record['metadata']:
                  record[key[1:]] = record['metadata'][key]
                  del record['metadata'][key]
          return record
docs: Prepare a record hit from Elasticsearch for serialization.