def to_marqo_document(self, return_highlights: bool = False) -> Dict[str, Any]:
        """Convert VespaDocumentObject back to the original document structure."""
        marqo_document = {}
        # Processing short_string_fields and long_string_fields back into original format
        marqo_document.update(self.fields.short_string_fields)
        marqo_document.update(self.fields.long_string_fields)
        # Reconstruct string arrays
        for string_array in self.fields.string_arrays:
            key, value = string_array.split("::", 1)
            if key not in marqo_document:
                marqo_document[key] = []
            marqo_document[key].append(value)

        # Add int and float fields back
        # Please note that int-map and float-map fields are flattened in the result. The correct behaviour is to convert
        # them back to the format when they are indexed. We will keep the behaviour as is to avoid breaking changes.
        marqo_document.update(self.fields.int_fields)
        marqo_document.update(self.fields.float_fields)

        marqo_document.update({k: bool(v) for k, v in self.fields.bool_fields.items()})
        marqo_document[index_constants.MARQO_DOC_ID] = self.fields.marqo__id

        # This normally means the document is return with show_vectors=True
        if self.fields.vespa_chunks and self.fields.vespa_embeddings:
            try:
                embeddings_list = list(self.fields.vespa_embeddings["blocks"].values())
            except (KeyError, AttributeError, TypeError) as e:
                raise VespaDocumentParsingError(f"Can not parsing embeddings for document "
                                                f"_id={self.fields.marqo__id}. "
                                                f"Document={self.fields.dict()}. "
                                                f"Original error message {e}")

            if not len(self.fields.vespa_chunks) == len(embeddings_list):
                raise VespaDocumentParsingError(f"Number of chunks and embeddings do not match "
                                                f"for document _id= {self.fields.marqo__id}")
            marqo_document[index_constants.MARQO_DOC_TENSORS] = dict()
            for chunk, embedding in zip(self.fields.vespa_chunks, embeddings_list):
                if "::" not in chunk:
                    raise VespaDocumentParsingError(f"Chunk {chunk} does not have a field_name::content format")
                field_name, content = chunk.split("::", 1)
                if field_name not in marqo_document[index_constants.MARQO_DOC_TENSORS]:
                    marqo_document[index_constants.MARQO_DOC_TENSORS][field_name] = dict()
                    marqo_document[index_constants.MARQO_DOC_TENSORS][field_name][index_constants.MARQO_DOC_CHUNKS]\
                        = []
                    marqo_document[index_constants.MARQO_DOC_TENSORS][field_name][
                        index_constants.MARQO_DOC_EMBEDDINGS] = []
                marqo_document[index_constants.MARQO_DOC_TENSORS][field_name] \
                    [index_constants.MARQO_DOC_CHUNKS].append(
                    content)
                marqo_document[index_constants.MARQO_DOC_TENSORS][field_name][
                    index_constants.MARQO_DOC_EMBEDDINGS].append(embedding)

        if self.fields.vespa_multimodal_params:
            marqo_document[unstructured_common.MARQO_DOC_MULTIMODAL_PARAMS] = dict()
            for multimodal_field_name, serialized_multimodal_params in self.fields.vespa_multimodal_params.items():
                marqo_document[unstructured_common.MARQO_DOC_MULTIMODAL_PARAMS][multimodal_field_name] = \
                    json.loads(serialized_multimodal_params)

        if return_highlights and self.fields.match_features:
            marqo_document[index_constants.MARQO_DOC_HIGHLIGHTS] = self.fields.extract_highlights()

        # Hybrid search raw scores
        if self.raw_tensor_score is not None:
            marqo_document[index_constants.MARQO_DOC_HYBRID_TENSOR_SCORE] = self.raw_tensor_score
        if self.raw_lexical_score is not None:
            marqo_document[index_constants.MARQO_DOC_HYBRID_LEXICAL_SCORE] = self.raw_lexical_score
        return marqo_document
Convert VespaDocumentObject back to the original document structure.
src/marqo/core/unstructured_vespa_index/unstructured_document.py