code: def _prepare_record(record, index, doc_type):
          
          if current_app.config['INDEXER_REPLACE_REFS']:
              data = copy.deepcopy(record.replace_refs())
          else:
              data = record.dumps()
  
          data['_created'] = pytz.utc.localize(record.created).isoformat() \
              if record.created else None
          data['_updated'] = pytz.utc.localize(record.updated).isoformat() \
              if record.updated else None
  
          # Allow modification of data prior to sending to Elasticsearch.
          before_record_index.send(
              current_app._get_current_object(),
              json=data,
              record=record,
              index=index,
              doc_type=doc_type,
          )
  
          return data
docs: Prepare record data for indexing.
  
          :param record: The record to prepare.
          :param index: The Elasticsearch index.
          :param doc_type: The Elasticsearch document type.
          :returns: The record metadata.