def _generate_max_similarity_expression(self, tensor_fields: List[TensorField]) -> str:
        """
        Recursively generate max closeness expression for all tensor fields.
        Max is a binary operator, so for more than 2 fields this method gets max of:
        1) first field
        2) max of the rest of the fields.

        prefixed arg determines whether to add "marqo__tensor_" prefix to tensor field name.
        """
        # Base cases
        # If no tensor fields, return empty string.
        # If only 1 or 2 tensor fields, get max of one/both.
        if len(tensor_fields) == 0:
            return ""
        else:
            embeddings_field_name = tensor_fields[0].embeddings_field_name
            if len(tensor_fields) == 1:
                return (f'if(query({embeddings_field_name}) > 0, '
                        f'closeness(field, {embeddings_field_name}), 0)')
            # Recursive step
            else:
                return (f'max('
                        f'if(query({embeddings_field_name}) > 0, '
                        f'closeness(field, {embeddings_field_name}), 0), '
                        f'{self._generate_max_similarity_expression(tensor_fields[1:])})')

        Recursively generate max closeness expression for all tensor fields.
        Max is a binary operator, so for more than 2 fields this method gets max of:
        1) first field
        2) max of the rest of the fields.

        prefixed arg determines whether to add "marqo__tensor_" prefix to tensor field name.
        
src/marqo/core/structured_vespa_index/structured_vespa_schema.py