code: def index_relations(sender, pid_type, json=None,
                      record=None, index=None, **kwargs):
      
      if not json:
          json = {}
      pid = PersistentIdentifier.query.filter(
          PersistentIdentifier.object_uuid == record.id,
          PersistentIdentifier.pid_type == pid_type,
      ).one_or_none()
      relations = None
      if pid:
          relations = serialize_relations(pid)
          if relations:
              json['relations'] = relations
      return json
docs: Add relations to the indexed record.